when browsing a relay, the publish button is prefilled to publish just on that.

This commit is contained in:
fiatjaf 2023-05-12 08:54:20 -03:00
parent faaac70c1a
commit ba6c630fab
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1
3 changed files with 9 additions and 5 deletions

View File

@ -8,10 +8,13 @@
const {canPublish} = user
const createNote = () => {
const matches = $location.pathname.match(/people\/(npub1[0-9a-z]+)/)
const pubkey = matches ? nip19.decode(matches[1]).data : null
const pubkeyMatch = $location.pathname.match(/people\/(npub1[0-9a-z]+)/)
const pubkey = pubkeyMatch ? nip19.decode(pubkeyMatch[1]).data : null
const relayMatch = $location.pathname.match(/relays\/(.+)/)
const relay = relayMatch ? relayMatch[1] : null
const relays = relay ? [relay] : null
modal.push({type: "note/create", pubkey})
modal.push({type: "note/create", pubkey, relays})
}
</script>

View File

@ -27,7 +27,7 @@
<NoteDetail {...m} invertColors />
{/key}
{:else if m.type === "note/create"}
<NoteCreate pubkey={m.pubkey} nevent={m.nevent} />
<NoteCreate pubkey={m.pubkey} nevent={m.nevent} writeTo={m.relays} />
{:else if m.type === "note/zap"}
<NoteZap note={m.note} />
{:else if m.type === "relay/add"}

View File

@ -25,12 +25,13 @@
export let pubkey = null
export let nevent = null
export let writeTo = null
let q = ""
let image = null
let compose = null
let showSettings = false
let relays = writable(getUserWriteRelays())
let relays = writable(writeTo ? writeTo.map(url => ({url, score: 1})) : getUserWriteRelays())
const onSubmit = async () => {
let {content, mentions, topics} = compose.parse()