kopia lustrzana https://github.com/nostr-protocol/nostr
quickfix for the Setup page.
rodzic
d7011916b9
commit
1f97baf39c
|
@ -16,18 +16,12 @@
|
|||
<section>
|
||||
<b>{{ showingIgnored ? 'Ignored relays' : 'Relays' }}:</b>
|
||||
|
||||
<a v-if="ignored.length" @click="showingIgnored = !showingIgnored"
|
||||
<a v-if="Object.keys($store.state.ignoredRelays).length" @click="showingIgnored = !showingIgnored"
|
||||
>show {{ showingIgnored ? 'active' : 'ignored' }}
|
||||
</a>
|
||||
<div v-if="showingIgnored" v-for="(relay, i) in (ignored || [])">
|
||||
{{ relay.host }}
|
||||
<span v-if="relay.recommender"
|
||||
>recommended by:
|
||||
<a :href="'#/' + relay.recommender">
|
||||
<Name :pubkey="relay.recommender" /> </a
|
||||
> </span
|
||||
>
|
||||
<button @click="e => unignoreRelay(e, relay.host)">Unignore</button>
|
||||
<div v-if="showingIgnored" v-for="host in $store.state.ignoredRelays">
|
||||
{{ host }}
|
||||
<button @click="e => unignoreRelay(e, host)">Unignore</button>
|
||||
</div>
|
||||
<div v-else v-for="(relay, i) in (relays || []).concat(null)">
|
||||
<form v-if="editing === i" @submit="saveRelay">
|
||||
|
@ -68,6 +62,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {pool} from './relay'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
@ -81,7 +77,15 @@
|
|||
},
|
||||
computed: {
|
||||
relays() {
|
||||
return this.$store.state.relays
|
||||
return Object.keys(pool.relays)
|
||||
.map(relayURL => {
|
||||
let relay = pool.relays[relayURL]
|
||||
|
||||
return {
|
||||
host: relayURL,
|
||||
policy: `${relay.policy.read ? 'r' : ''}${relay.policy.write ? 'w' : ''}`
|
||||
}
|
||||
})
|
||||
.filter(({policy}) => policy !== 'i')
|
||||
.sort((a, b) => {
|
||||
let pa = a.policy
|
||||
|
@ -94,9 +98,6 @@
|
|||
return 0
|
||||
})
|
||||
},
|
||||
ignored() {
|
||||
return this.$store.state.relays.filter(({policy}) => policy === 'i')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isValidKey(key) {
|
||||
|
@ -128,7 +129,7 @@
|
|||
}
|
||||
this.editing = i
|
||||
},
|
||||
saveRelay(e) {
|
||||
async saveRelay(e) {
|
||||
e.preventDefault()
|
||||
|
||||
let relay = {
|
||||
|
@ -137,27 +138,31 @@
|
|||
}
|
||||
|
||||
if (this.editing === this.relays.length) {
|
||||
this.$store.dispatch('addRelay', relay)
|
||||
await this.$store.dispatch('addRelay', relay)
|
||||
} else if (this.editing >= 0) {
|
||||
this.$store.dispatch('updateRelay', {
|
||||
await this.$store.dispatch('updateRelay', {
|
||||
...relay,
|
||||
key: this.relays[this.editing].host
|
||||
})
|
||||
}
|
||||
|
||||
this.editing = null
|
||||
this.$forceUpdate()
|
||||
},
|
||||
recommendRelay(e, host) {
|
||||
async recommendRelay(e, host) {
|
||||
e.preventDefault()
|
||||
this.$store.dispatch('recommendRelay', host)
|
||||
this.$forceUpdate()
|
||||
},
|
||||
ignoreRelay(e, host) {
|
||||
async ignoreRelay(e, host) {
|
||||
e.preventDefault()
|
||||
this.$store.dispatch('updateRelay', {key: host, host, policy: 'i'})
|
||||
await this.$store.dispatch('updateRelay', {key: host, host, policy: 'i'})
|
||||
this.$forceUpdate()
|
||||
},
|
||||
unignoreRelay(e, host) {
|
||||
async unignoreRelay(e, host) {
|
||||
e.preventDefault()
|
||||
this.$store.dispatch('updateRelay', {key: host, host, policy: ''})
|
||||
await this.$store.dispatch('updateRelay', {key: host, host, policy: ''})
|
||||
this.$forceUpdate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// vuex store actions
|
||||
|
||||
import {verifySignature} from 'nostr-tools'
|
||||
import {overwriteEvent} from './helpers'
|
||||
import {parsePolicy, overwriteEvent} from './helpers'
|
||||
import {
|
||||
CONTEXT_NOW,
|
||||
CONTEXT_REQUESTED,
|
||||
|
@ -155,12 +155,21 @@ export default {
|
|||
},
|
||||
async addRelay(store, relay) {
|
||||
await db.relays.put(relay)
|
||||
store.commit('loadedRelays', await db.relays.toArray())
|
||||
pool.addRelay(relay.host, relay.policy)
|
||||
},
|
||||
async updateRelay(store, {key, host, policy}) {
|
||||
let relay = {host, policy}
|
||||
await db.relays.update(key, relay)
|
||||
store.commit('loadedRelays', await db.relays.toArray())
|
||||
pool.removeRelay(host)
|
||||
|
||||
if (policy.length && policy.indexOf('i') !== 'i') {
|
||||
pool.addRelay(host, parsePolicy(policy))
|
||||
}
|
||||
|
||||
store.commit('unignoreRelay', host)
|
||||
if (policy.indexOf('i') !== -1) {
|
||||
store.commit('ignoreRelay', host)
|
||||
}
|
||||
},
|
||||
async publishMetadata(store, meta) {
|
||||
let event = await pool.publish({
|
||||
|
|
|
@ -100,7 +100,12 @@ export default {
|
|||
state.home.set(evt.id + ':' + evt.created_at, evt)
|
||||
}
|
||||
},
|
||||
saveMyOwnNote() {},
|
||||
ignoreRelay(state, host) {
|
||||
state.ignoredRelays[host] = true
|
||||
},
|
||||
unignoreRelay(state, host) {
|
||||
delete state.ignoredRelays[host]
|
||||
},
|
||||
updatePublishStatus(state, {id, time, relay, status}) {
|
||||
state.publishStatus = {
|
||||
...state.publishStatus,
|
||||
|
|
|
@ -11,19 +11,24 @@ const hardcodedRelays = [
|
|||
policy: 'rw'
|
||||
}
|
||||
]
|
||||
db.relays
|
||||
.bulkPut(hardcodedRelays)
|
||||
.then(() => db.relays.toArray())
|
||||
.then(relays => {
|
||||
relays.forEach(({host, policy}) => {
|
||||
let relay = pool.addRelay(host, parsePolicy(policy))
|
||||
setTimeout(() => {
|
||||
relay.reqFeed()
|
||||
}, 1)
|
||||
})
|
||||
})
|
||||
|
||||
export function relayStorePlugin(store) {
|
||||
db.relays
|
||||
.bulkPut(hardcodedRelays)
|
||||
.then(() => db.relays.toArray())
|
||||
.then(relays => {
|
||||
relays.forEach(({host, policy}) => {
|
||||
if (policy.indexOf('i') !== -1) {
|
||||
store.commit('ignoreRelay', host)
|
||||
}
|
||||
|
||||
let relay = pool.addRelay(host, parsePolicy(policy))
|
||||
setTimeout(() => {
|
||||
relay.reqFeed()
|
||||
}, 1)
|
||||
})
|
||||
})
|
||||
|
||||
store.subscribe(mutation => {
|
||||
switch (mutation.type) {
|
||||
case 'setInit':
|
||||
|
|
|
@ -29,7 +29,8 @@ export default createStore({
|
|||
metadata: new LRU({maxSize: 100}),
|
||||
browsing: new LRU({maxSize: 500}),
|
||||
publishStatus: {},
|
||||
petnames: {}
|
||||
petnames: {},
|
||||
ignoredRelays: {},
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
|
|
Ładowanie…
Reference in New Issue