import Component from '@glimmer/component'; import { action } from '@ember/object'; import { service } from '@ember/service'; import Icon from '#components/icon'; import { on } from '@ember/modifier'; import { tracked } from '@glimmer/tracking'; import { eq } from 'ember-truth-helpers'; import Modal from './modal'; export default class UserMenuComponent extends Component { @service storage; @service osmAuth; @service nostrAuth; @tracked isNostrConnectModalOpen = false; @action connectRS() { this.args.onClose(); this.args.storage.showConnectWidget(); } @action disconnectRS() { this.args.storage.disconnect(); } @action connectOsm() { this.args.onClose(); this.osmAuth.login(); } @action disconnectOsm() { this.osmAuth.logout(); } @action openNostrConnectModal() { this.isNostrConnectModalOpen = true; } @action closeNostrConnectModal() { this.isNostrConnectModalOpen = false; } @action async connectNostrExtension() { try { await this.nostrAuth.login('extension'); this.closeNostrConnectModal(); } catch (e) { console.error(e); alert(e.message); } } @action async connectNostrApp() { try { await this.nostrAuth.login('connect'); this.closeNostrConnectModal(); } catch (e) { console.error(e); alert(e.message); } } @action disconnectNostr() { this.nostrAuth.logout(); } get hasExtension() { return typeof window !== 'undefined' && typeof window.nostr !== 'undefined'; } }