fix(collab): note attachments added or removed on the phone show in the Files tab at once

On the phone, attaching a file to a note, detaching one or deleting a
note with attachments left the trip's Files tab on the old list until a
reload. The desktop panel fires the local collab-files-changed event
that useTripWebSocket listens for, because the server leaves the
writer's own socket out of its broadcast; the phone notes tab never
fired it.

The event now lives in the shared useCollabNotesData hook:
uploadNoteFiles announces it once after a batch, and
announceNoteFilesChanged is what both shells call after deleting a note
or a note file. The desktop no longer fires it by hand after an upload.

Red before the fix: tests/unit/mobile/trip/MCollabNotes.test.tsx
FE-MOB-CNOTE-034 failed with "expected 0 to be 1" on the event count
after detaching a file. FE-COLLAB-NOTESDATA-009 covers the hook.
No existing assertions changed.
This commit is contained in:
Maurice
2026-10-09 17:26:25 +02:00
parent 0246e5c317
commit f19b52fb20
5 changed files with 69 additions and 8 deletions
@@ -6,7 +6,7 @@ import { sanitizedMarkdownPlugins, sanitizedMarkdownComponents } from '../../../
import { Check, ExternalLink, FileText, Paperclip, Pin, PinOff, Plus, StickyNote, Trash2, X } from 'lucide-react'
import MDancingTrek from '../../../components/MDancingTrek'
import { collabApi } from '../../../../api/client'
import { useCollabNotesData } from '../../../../components/Collab/useCollabNotesData'
import { announceNoteFilesChanged, useCollabNotesData } from '../../../../components/Collab/useCollabNotesData'
import { openFile } from '../../../../utils/fileDownload'
import { safeExternalHref } from '../../../../utils/safeUrl'
import MSheet from '../../../components/MSheet'
@@ -115,6 +115,7 @@ export default function MCollabNotes({ planner }: MCollabNotesProps) {
try {
await collabApi.deleteNote(tripId, noteId)
setNotes(prev => prev.filter(n => n.id !== noteId))
announceNoteFilesChanged()
} catch {
toast.error(t('common.error'))
}
@@ -128,6 +129,7 @@ export default function MCollabNotes({ planner }: MCollabNotesProps) {
setNotes(prev => prev.map(n => (
n.id === noteId ? { ...n, attachments: n.attachments.filter(f => f.id !== fileId) } : n
)))
announceNoteFilesChanged()
return true
} catch {
toast.error(t('common.error'))