diff --git a/README.md b/README.md
index 56856af7..f51bfbbe 100644
--- a/README.md
+++ b/README.md
@@ -77,20 +77,20 @@ If you like Coracle and want to support its development, you can donate sats via
- [x] Still use "my" relays for global, this could make global feed more useful
- [x] If we use my relays for global, we don't have to wait for network to load initially
- [x] Figure out fast vs complete tradeoff. Skipping loadContext speeds things up a ton.
-- [ ] Add relays/mentions to note and reply composition
+- [x] Add relays/mentions to note and reply composition
- [ ] Figure out migrations from previous version
- [ ] Fix search
-- [ ] Move add note to modal
## 0.2.7
+- [x] Added error tracking - you can turn this off in settings
- [x] Add support for profile banner images
- [x] Re-designed relays page
- [x] Support connection status/speed indication
- [x] Add toggle to enable writing to a connected relay
- [x] Re-designed login page
- [x] Use private key login only if extension is not enabled
- - [x] Add pubkey login
+ - [x] Add pubkey login support
## 0.2.6
diff --git a/src/App.svelte b/src/App.svelte
index 5eda00e9..2337e699 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -9,7 +9,6 @@
import {cubicInOut} from "svelte/easing"
import {Router, Route, links, navigate} from "svelte-routing"
import {globalHistory} from "svelte-routing/src/history"
- import {hasParent} from 'src/util/html'
import {displayPerson, isLike} from 'src/util/nostr'
import {timedelta, now} from 'src/util/misc'
import {keys, user, pool, getRelays} from 'src/agent'
diff --git a/src/agent/index.js b/src/agent/index.js
index 419c8dac..6d029d6d 100644
--- a/src/agent/index.js
+++ b/src/agent/index.js
@@ -1,4 +1,4 @@
-import {last, objOf, uniq} from 'ramda'
+import {last, uniqBy, prop, objOf, uniq} from 'ramda'
import {derived, get} from 'svelte/store'
import {Tags} from 'src/util/nostr'
import pool from 'src/agent/pool'
@@ -52,11 +52,12 @@ export const getRelays = pubkey => {
}
export const getEventRelays = event => {
- return uniq(
+ return uniqBy(
+ prop('url'),
getRelays(event.pubkey)
.concat(Tags.from(event).relays())
- .concat(event.seen_on)
- ).map(objOf('url'))
+ .concat({url: event.seen_on})
+ )
}
export const publish = async (relays, event) => {
diff --git a/src/app/cmd.js b/src/app/cmd.js
index 60b40d0b..e705de14 100644
--- a/src/app/cmd.js
+++ b/src/app/cmd.js
@@ -1,7 +1,7 @@
import {prop, join, uniqBy, last} from 'ramda'
import {get} from 'svelte/store'
import {first} from "hurdak/lib/hurdak"
-import {Tags} from 'src/util/nostr'
+import {Tags, isRelay} from 'src/util/nostr'
import {keys, publish, getRelays} from 'src/agent'
const updateUser = (relays, updates) =>
@@ -25,11 +25,15 @@ const updateRoom = (relays, {id, ...room}) =>
const createMessage = (relays, roomId, content) =>
publishEvent(relays, 42, {content, tags: [["e", roomId, first(relays), "root"]]})
-const createNote = (relays, content, mentions = []) =>
- publishEvent(relays, 1, {content, tags: mentions.map(p => ["p", p, first(getRelays(p))])})
+const createNote = (relays, content, mentions = [], topics = []) => {
+ mentions = mentions.map(p => ["p", p, prop('url', first(getRelays(p)))])
+ topics = topics.map(t => ["t", t])
+
+ publishEvent(relays, 1, {content, tags: mentions.concat(topics)})
+}
const createReaction = (relays, note, content) => {
- const {url} = getBestRelay(note)
+ const {url} = getBestRelay(relays, note)
const tags = uniqBy(
join(':'),
note.tags
@@ -41,17 +45,22 @@ const createReaction = (relays, note, content) => {
return publishEvent(relays, 7, {content, tags})
}
-const createReply = (relays, note, content, mentions = []) => {
- const {url} = getBestRelay(note)
+const createReply = (relays, note, content, mentions = [], topics = []) => {
+ mentions = mentions.map(p => ["p", p, prop('url', first(getRelays(p)))])
+ topics = topics.map(t => ["t", t])
+
+ const {url} = getBestRelay(relays, note)
const tags = uniqBy(
join(':'),
note.tags
- .filter(t => ["p", "e"].includes(t[0]))
+ .filter(t => ["e"].includes(t[0]))
.map(t => last(t) === 'reply' ? t.slice(0, -1) : t)
.concat([["p", note.pubkey, url], ["e", note.id, url, 'reply']])
- .concat(mentions.map(p => ["p", p, prop('url', first(getRelays(p)))]))
+ .concat(mentions.concat(topics))
)
+ console.log(relays)
+
return publishEvent(relays, 1, {content, tags})
}
@@ -60,21 +69,22 @@ const deleteEvent = (relays, ids) =>
// Utils
-const getBestRelay = event => {
- // Find the best relay, based on reply, root, or pubkey
- const reply = Tags.from(event).type("e").mark("reply").first()
+const getBestRelay = (relays, event) => {
+ // Find the best relay, based on reply, root, or pubkey. Fall back to a
+ // relay we're going to send the event to
+ const tags = Tags.from(event).type("e")
+ const reply = tags.mark("reply").values().first()
+ const root = tags.mark("root").values().first()
- if (reply && reply[2].startsWith('ws')) {
- return reply[2]
+ if (isRelay(reply)) {
+ return reply
}
- const root = Tags.from(event).type("e").mark("root").first()
-
- if (root && root[2].startsWith('ws')) {
- return root[2]
+ if (isRelay(root)) {
+ return root
}
- return first(getRelays(event.pubkey))
+ return first(getRelays(event.pubkey).concat(relays))
}
const publishEvent = (relays, kind, {content = '', tags = []} = {}) => {
diff --git a/src/partials/Compose.svelte b/src/partials/Compose.svelte
index fea9088b..525fe1a7 100644
--- a/src/partials/Compose.svelte
+++ b/src/partials/Compose.svelte
@@ -1,5 +1,6 @@
@@ -154,12 +176,17 @@
on:keyup={onKeyUp} />