fix(ui): refresh mesh transport labels after send
This commit is contained in:
parent
a91814641e
commit
2ac0711f8e
@ -243,6 +243,15 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshMessagesAfterSend() {
|
||||
await fetchMessages()
|
||||
// Federation sends stamp FIPS/Tor asynchronously after the RPC returns.
|
||||
// Poll briefly so the transport pill settles without a browser refresh.
|
||||
for (const delay of [350, 900, 1600]) {
|
||||
setTimeout(() => { void fetchMessages() }, delay)
|
||||
}
|
||||
}
|
||||
|
||||
// Convert microdegrees (from mesh protocol) to degrees for Leaflet
|
||||
// Values > 90 for lat or > 180 for lng indicate microdegrees
|
||||
function toDegreesIfMicro(lat: number, lng: number): { lat: number; lng: number } {
|
||||
@ -322,7 +331,7 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
})
|
||||
// Refresh messages after sending
|
||||
if (res.sent) {
|
||||
await fetchMessages()
|
||||
await refreshMessagesAfterSend()
|
||||
}
|
||||
return res
|
||||
} catch (err: unknown) {
|
||||
@ -347,9 +356,7 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
method: 'mesh.send-channel',
|
||||
params: { channel, message: message.trim() },
|
||||
})
|
||||
if (res.sent) {
|
||||
await fetchMessages()
|
||||
}
|
||||
if (res.sent) await refreshMessagesAfterSend()
|
||||
return res
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to send channel message'
|
||||
@ -440,7 +447,7 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
method: 'mesh.send-content',
|
||||
params: { contact_id: contactId, cid, caption, peer_onion: peerOnion },
|
||||
})
|
||||
if (res.sent) await fetchMessages()
|
||||
if (res.sent) await refreshMessagesAfterSend()
|
||||
return res
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to send content'
|
||||
@ -483,7 +490,7 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
method: 'mesh.send-content-inline',
|
||||
params: { contact_id: contactId, mime, filename, caption, bytes_b64 },
|
||||
})
|
||||
if (res.sent) await fetchMessages()
|
||||
if (res.sent) await refreshMessagesAfterSend()
|
||||
return res
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to send inline content'
|
||||
@ -500,7 +507,7 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
method: 'mesh.send-reply',
|
||||
params: { contact_id: contactId, target_pubkey: targetPubkey, target_seq: targetSeq, text },
|
||||
})
|
||||
if (res.sent) await fetchMessages()
|
||||
if (res.sent) await refreshMessagesAfterSend()
|
||||
return res
|
||||
} finally {
|
||||
sending.value = false
|
||||
@ -513,7 +520,7 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
method: 'mesh.send-reaction',
|
||||
params: { contact_id: contactId, target_pubkey: targetPubkey, target_seq: targetSeq, emoji },
|
||||
})
|
||||
if (res.sent) await fetchMessages()
|
||||
if (res.sent) await refreshMessagesAfterSend()
|
||||
return res
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to send reaction'
|
||||
@ -549,7 +556,7 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
method: 'mesh.forward-message',
|
||||
params: { contact_id: contactId, source_message_id: sourceMessageId },
|
||||
})
|
||||
if (res.sent) await fetchMessages()
|
||||
if (res.sent) await refreshMessagesAfterSend()
|
||||
return res
|
||||
} finally {
|
||||
sending.value = false
|
||||
@ -562,7 +569,7 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
method: 'mesh.edit-message',
|
||||
params: { contact_id: contactId, target_seq: targetSeq, new_text: newText },
|
||||
})
|
||||
if (res.sent) await fetchMessages()
|
||||
if (res.sent) await refreshMessagesAfterSend()
|
||||
return res
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to edit message'
|
||||
@ -576,7 +583,7 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
method: 'mesh.delete-message',
|
||||
params: { contact_id: contactId, target_seq: targetSeq },
|
||||
})
|
||||
if (res.sent) await fetchMessages()
|
||||
if (res.sent) await refreshMessagesAfterSend()
|
||||
return res
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to delete message'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user