refactor(files): keep each view's id rules in the shared link toggle

The shared toggle had mixed the two views. Desktop again treats any empty
column as free and finds a link record by comparing ids as they come. The
phone link sheet again treats only a null column as free and compares the
numeric value of a record id.

Starring stays per view. It is a single filesApi call with different
error handling and refresh on each side, so a shared wrapper would add a
layer without removing any logic.
This commit is contained in:
Maurice
2026-10-09 11:20:03 +02:00
parent a809de1b7a
commit c9c3cc6175
3 changed files with 69 additions and 17 deletions
@@ -2,7 +2,7 @@ import { useRef, useState } from 'react'
import { Check, Link2, Loader2, MapPin, Ticket, TrainFront } from 'lucide-react'
import type { LucideIcon } from 'lucide-react'
import MSheet from '../../../components/MSheet'
import { toggleFileLink, type FileLinkField } from '../../../../components/Files/fileActions'
import { PHONE_FILE_LINK_RULES, toggleFileLink, type FileLinkField } from '../../../../components/Files/fileActions'
import type { TripFile } from '../../../../types'
import type { TripPlanner } from '../MTripShell'
import { Eyebrow, TileHeader } from '../sheets/MTripSheetUi'
@@ -48,7 +48,7 @@ export default function MFileLinkSheet({ planner, file, onClose }: MFileLinkShee
const key = `${field === 'place_id' ? 'p' : 'r'}${targetId}`
setBusyKey(key)
try {
await toggleFileLink(tripId, shown, field, targetId)
await toggleFileLink(tripId, shown, field, targetId, PHONE_FILE_LINK_RULES)
refresh()
} catch {
toast.error(t('files.toast.assignError'))