mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-21 06:11:45 +00:00
fix(journey): websocket sync across devices + 404 redirect
- broadcastJourneyEvent now excludes by socket ID instead of user ID, so other devices of the same user receive real-time updates (#615) - Routes pass x-socket-id header through to broadcast functions - loadJourney handles 404 gracefully — redirects to /journey with toast instead of infinite spinner (#616)
This commit is contained in:
@@ -88,6 +88,7 @@ interface JourneyState {
|
||||
journeys: Journey[]
|
||||
current: JourneyDetail | null
|
||||
loading: boolean
|
||||
notFound: boolean
|
||||
|
||||
loadJourneys: () => Promise<void>
|
||||
loadJourney: (id: number) => Promise<void>
|
||||
@@ -109,6 +110,7 @@ export const useJourneyStore = create<JourneyState>((set, get) => ({
|
||||
journeys: [],
|
||||
current: null,
|
||||
loading: false,
|
||||
notFound: false,
|
||||
|
||||
loadJourneys: async () => {
|
||||
set({ loading: true })
|
||||
@@ -121,10 +123,14 @@ export const useJourneyStore = create<JourneyState>((set, get) => ({
|
||||
},
|
||||
|
||||
loadJourney: async (id) => {
|
||||
set({ loading: true })
|
||||
set({ loading: true, notFound: false })
|
||||
try {
|
||||
const data = await journeyApi.get(id)
|
||||
set({ current: data })
|
||||
} catch (err: any) {
|
||||
if (err?.response?.status === 404) {
|
||||
set({ current: null, notFound: true })
|
||||
}
|
||||
} finally {
|
||||
set({ loading: false })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user