mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 02:14:05 +00:00
feat(planner): show the stop a booked night writes without a reload
The server announces the day stop over the socket like any other assignment, but the socket deliberately skips the session that sent the request, so the one person who could not see their new stop was the one who had just booked the night. That looks exactly like the bug it fixes. The stay writes hand their answer to one applier, which folds the stop into the store through the same path the socket uses, so the IndexedDB write-through happens either way and the dedupe by assignment id comes for free. Three surfaces call it: the day-detail picker, its edit branch and the phone sheet. The road-trip flow does not, because it writes its own assignment before the stay and there is never a mirrored stop to apply.
This commit is contained in:
@@ -5,6 +5,7 @@ import MIconBtn from '../../../components/MIconBtn'
|
||||
import CustomSelect from '../../../../components/shared/CustomSelect'
|
||||
import CustomTimePicker from '../../../../components/shared/CustomTimePicker'
|
||||
import { accommodationsApi } from '../../../../api/client'
|
||||
import { applyStayStops } from '../../../../store/stayStops'
|
||||
import { useTranslation } from '../../../../i18n'
|
||||
import { Eyebrow } from './MTripSheetUi'
|
||||
import type { MTripSheetsProps } from '../MTripShell'
|
||||
@@ -111,8 +112,9 @@ export default function MAccommodationSheet({ planner, shell }: MTripSheetsProps
|
||||
// Only the write itself decides whether the save failed — a refresh that
|
||||
// trips afterwards must not be reported as a failed save.
|
||||
try {
|
||||
if (editing) await accommodationsApi.update(tripId, editing.id, body)
|
||||
else await accommodationsApi.create(tripId, body)
|
||||
applyStayStops(editing
|
||||
? await accommodationsApi.update(tripId, editing.id, body)
|
||||
: await accommodationsApi.create(tripId, body))
|
||||
} catch {
|
||||
planner.toast.error(t('common.error'))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user