diff --git a/src/components/Settings/RelaySettings.vue b/src/components/Settings/RelaySettings.vue new file mode 100644 index 0000000..63444c4 --- /dev/null +++ b/src/components/Settings/RelaySettings.vue @@ -0,0 +1,134 @@ + + + + + diff --git a/src/nostr/NostrClient.js b/src/nostr/NostrClient.js index 2ec2a9c..073036d 100644 --- a/src/nostr/NostrClient.js +++ b/src/nostr/NostrClient.js @@ -20,6 +20,11 @@ export default class NostrClient { return this.pool.connectedRelays() } + isConnectedTo(url) { + // TODO remove linear scan + return this.connectedRelays().some(relay => relay.url === url) + } + subscribe(filters, subId = null) { return this.pool.subscribe(filters, subId) } diff --git a/src/pages/Settings.vue b/src/pages/Settings.vue index e61c146..d177792 100644 --- a/src/pages/Settings.vue +++ b/src/pages/Settings.vue @@ -1,19 +1,26 @@ diff --git a/src/stores/Settings.js b/src/stores/Settings.js index bcbbead..e6ee3ba 100644 --- a/src/stores/Settings.js +++ b/src/stores/Settings.js @@ -53,13 +53,17 @@ export const useSettingsStore = defineStore('settings', { this.pubkey = pubkey }, addRelay(url) { + if (this.hasRelay(url)) return this.relays.push(url) }, removeRelay(url) { const idx = this.relays.indexOf(url) if (idx < 0) return this.relays.splice(idx, 1) - } + }, + hasRelay(url) { + return this.relays.indexOf(url) >= 0 + }, }, persist: true, })