diff --git a/src/boot/global-components.js b/src/boot/global-components.js index 3075581..723f254 100644 --- a/src/boot/global-components.js +++ b/src/boot/global-components.js @@ -1,4 +1,5 @@ import RawEventData from '../components/RawEventData.vue' +import Recommend from '../components/Recommend.vue' import Markdown from '../components/Markdown.vue' import ShowMore from '../components/ShowMore.vue' import Publish from '../components/Publish.vue' @@ -11,6 +12,7 @@ import Name from '../components/Name.vue' export default ({app}) => { app.component('RawEventData', RawEventData) + app.component('Recommend', Recommend) app.component('Markdown', Markdown) app.component('ShowMore', ShowMore) app.component('Publish', Publish) diff --git a/src/components/Post.vue b/src/components/Post.vue index 2bf1d21..6dd5828 100644 --- a/src/components/Post.vue +++ b/src/components/Post.vue @@ -71,7 +71,7 @@ @mousedown="startClicking" @mouseup="finishClicking" > - + {{ trimmedContent }} + @@ -148,10 +149,12 @@ export default { methods: { startClicking() { + if (this.event.kind === 2) return + this.clicking = true setTimeout(() => { this.clicking = false - }, 300) + }, 200) }, finishClicking(ev) { diff --git a/src/components/Recommend.vue b/src/components/Recommend.vue new file mode 100644 index 0000000..b37e9c0 --- /dev/null +++ b/src/components/Recommend.vue @@ -0,0 +1,45 @@ + + + diff --git a/src/pages/Profile.vue b/src/pages/Profile.vue index 712aa0e..1c3b673 100644 --- a/src/pages/Profile.vue +++ b/src/pages/Profile.vue @@ -177,7 +177,7 @@ export default { filter: [ { authors: [this.$route.params.pubkey], - kinds: [0, 1, 3] + kinds: [0, 1, 2, 3] } ], cb: async (event, relay) => { @@ -187,6 +187,7 @@ export default { return case 1: + case 2: if (this.eventsSet.has(event.id)) return this.eventsSet.add(event.id) diff --git a/src/pages/Settings.vue b/src/pages/Settings.vue index 9b24a12..924ab62 100644 --- a/src/pages/Settings.vue +++ b/src/pages/Settings.vue @@ -55,6 +55,13 @@ @click="removeRelay(url)" /> {{ url }} + @@ -165,7 +172,8 @@ export default { about, nip05 }, - unsubscribe: null + unsubscribe: null, + hasJustSharedRelay: false } }, @@ -242,6 +250,13 @@ export default { setRelayOpt(url, opt, value) { this.$store.commit('setRelayOpt', {url, opt, value}) }, + shareRelay(url) { + this.hasJustSharedRelay = true + this.$store.dispatch('recommendServer', url) + setTimeout(() => { + this.hasJustSharedRelay = false + }, 5000) + }, async hardReset() { this.$q .dialog({ diff --git a/src/store/actions.js b/src/store/actions.js index fa3dfea..226d35a 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -181,6 +181,16 @@ export async function setMetadata(store, metadata) { store.dispatch('addEvent', {event}) } +export async function recommendServer(store, url) { + await pool.publish({ + pubkey: store.state.keys.pub, + created_at: Math.round(Date.now() / 1000), + kind: 2, + tags: [], + content: url + }) +} + export async function sendChatMessage(store, {now, pubkey, text, replyTo}) { if (text.length === 0) return diff --git a/src/worker-db.js b/src/worker-db.js index 5c41d33..0dc6c27 100644 --- a/src/worker-db.js +++ b/src/worker-db.js @@ -18,7 +18,7 @@ const db = new PouchDB('nostr-events', { // db schema (views) // ~ -const DESIGN_VERSION = 3 +const DESIGN_VERSION = 4 db.upsert('_design/main', current => { if (current && current.version >= DESIGN_VERSION) return false @@ -34,7 +34,7 @@ db.upsert('_design/main', current => { }, homefeed: { map: function (event) { - if (event.kind === 1) { + if (event.kind === 1 || event.kind === 2) { emit(event.created_at) } }.toString()