mirror of
https://github.com/styppo/hamstr.git
synced 2024-10-18 05:23:28 +00:00
Add more default relays
This commit is contained in:
parent
38b8c2cde2
commit
28ea16298d
@ -5,8 +5,11 @@ const RELAYS = [
|
||||
'wss://relay.snort.social',
|
||||
'wss://relay.nostr.ch',
|
||||
'wss://nos.lol',
|
||||
'wss://nostr-pub.semisol.dev',
|
||||
'wss://nostr.einundzwanzig.space',
|
||||
'wss://nostr.sg',
|
||||
]
|
||||
const RELAYS_VERSION = 1
|
||||
const RELAYS_VERSION = 2
|
||||
|
||||
export const useSettingsStore = defineStore('settings', {
|
||||
state: () => ({
|
||||
@ -30,7 +33,7 @@ export const useSettingsStore = defineStore('settings', {
|
||||
},
|
||||
actions: {
|
||||
init() {
|
||||
if (this.relaysVersion < RELAYS_VERSION) {
|
||||
if (this.relaysVersion < RELAYS_VERSION && this.hasSubsetOfDefaultRelays()) {
|
||||
this.relays = [].concat(RELAYS)
|
||||
this.relaysVersion = RELAYS_VERSION
|
||||
}
|
||||
@ -64,8 +67,7 @@ export const useSettingsStore = defineStore('settings', {
|
||||
},
|
||||
removeRelay(url) {
|
||||
const idx = this.relays.indexOf(url)
|
||||
if (idx < 0) return
|
||||
this.relays.splice(idx, 1)
|
||||
if (idx >= 0) this.relays.splice(idx, 1)
|
||||
},
|
||||
restoreDefaultRelays() {
|
||||
this.relays = [].concat(RELAYS)
|
||||
@ -74,6 +76,10 @@ export const useSettingsStore = defineStore('settings', {
|
||||
return this.relays.length === RELAYS.length
|
||||
&& this.relays.every((url, idx) => url === RELAYS[idx])
|
||||
},
|
||||
hasSubsetOfDefaultRelays() {
|
||||
return this.relays.length < RELAYS.length
|
||||
&& this.relays.every((url, idx) => RELAYS.indexOf(url) >= 0)
|
||||
},
|
||||
},
|
||||
persist: true,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user