fix(m1): wrap onMounted drain in try/catch so listen is always set up
This commit is contained in:
parent
8195ad98b0
commit
db3694d9cf
1 changed files with 8 additions and 5 deletions
|
|
@ -46,13 +46,16 @@ const messagesEl = ref<HTMLElement | null>(null)
|
||||||
let unlisten: UnlistenFn | null = null
|
let unlisten: UnlistenFn | null = null
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// Drain any events that fired while the panel was closed
|
try {
|
||||||
const pending = await invoke<RobinEvent[]>('get_pending_events')
|
const pending = await invoke<RobinEvent[]>('get_pending_events')
|
||||||
for (const e of pending) {
|
for (const e of pending) {
|
||||||
pushRobinEvent(e)
|
pushRobinEvent(e)
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('Robin: failed to drain pending events:', err)
|
||||||
|
}
|
||||||
|
|
||||||
// Listen for live events while panel is open
|
// Always set up the live listener, even if drain failed
|
||||||
unlisten = await listen<RobinEvent>('robin:event', ({ payload }) => {
|
unlisten = await listen<RobinEvent>('robin:event', ({ payload }) => {
|
||||||
pushRobinEvent(payload)
|
pushRobinEvent(payload)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue