Files
BRETT/app/composables/useViewingThread.ts
T
FliesentischKingandDevin 8e822e031d Suppress notifications for threads the user is currently viewing
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-17 22:52:53 +02:00

21 lines
765 B
TypeScript

// Modul-Singleton: welcher Thread gerade offen ist. Wird dem Server per WS
// mitgeteilt, damit fuer den sichtbaren Thread keine Benachrichtigung
// erzeugt wird (der Kommentar erscheint ja live im Thread).
let sender: ((payload: unknown) => void) | null = null
let current: string | null = null
export function useViewingThread() {
function setViewing(uploadId: string | null) {
current = uploadId
sender?.({ type: 'viewing', uploadId })
}
return { setViewing }
}
// Vom WS-Plugin aufgerufen, sobald der Socket offen ist - sendet dabei den
// zuletzt bekannten Thread nochmal (Reconnect-Sicherheit)
export function bindViewingSocket(send: (payload: unknown) => void) {
sender = send
if (current) send({ type: 'viewing', uploadId: current })
}