feat(web5): surface multi-relay publish result on profile save
Pairs with the backend change that broadcasts kind:0 to every
enabled relay. Web5Identities.vue's publishProfile() now reads the
richer response ({accepted, rejected, relays_attempted, published})
and shows one of three states:
- all relays accepted → "Published to all N relays (event_id…)"
- partial → "Published to X/N relays" plus a warning with the first
relay's rejection reason
- zero → "Published to 0/N relays — check Manage Relays" (error)
User can now tell at a glance whether their profile actually made
it to the wider nostr network or only the local relay.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -555,12 +555,29 @@ async function publishProfile() {
|
||||
method: 'identity.update-profile',
|
||||
params: { id: profileEditorIdentity.value.id, ...profileForm.value },
|
||||
})
|
||||
const res = await rpcClient.call<{ event_id: string }>({
|
||||
const res = await rpcClient.call<{
|
||||
event_id: string
|
||||
accepted: string[]
|
||||
rejected: Array<[string, string]>
|
||||
relays_attempted: number
|
||||
published: boolean
|
||||
}>({
|
||||
method: 'identity.publish-profile',
|
||||
params: { id: profileEditorIdentity.value.id },
|
||||
})
|
||||
await loadIdentities()
|
||||
profileSuccess.value = `Published to relay (${res.event_id.slice(0, 12)}...)`
|
||||
const n = res.accepted?.length ?? 0
|
||||
const total = res.relays_attempted ?? 0
|
||||
const tail = `(${res.event_id.slice(0, 12)}…)`
|
||||
if (n === total) {
|
||||
profileSuccess.value = `Published to all ${total} relays ${tail}`
|
||||
} else if (n > 0) {
|
||||
profileSuccess.value = `Published to ${n}/${total} relays ${tail}`
|
||||
const first = res.rejected?.[0]
|
||||
if (first) profileError.value = `Rejected by ${first[0]}: ${first[1]}`
|
||||
} else {
|
||||
profileError.value = `Published to 0/${total} relays — check Manage Relays`
|
||||
}
|
||||
setTimeout(() => { profileSuccess.value = '' }, 5000)
|
||||
} catch (err: unknown) {
|
||||
profileError.value = err instanceof Error ? err.message : 'Failed to publish'
|
||||
|
||||
Reference in New Issue
Block a user