fix: use $api.queryOptions for batcher query keys

Replace custom meetingStatusKeys with $api.queryOptions()-derived keys
so cache identity matches the original per-room GET endpoints.
This commit is contained in:
Igor Loskutov
2026-02-05 19:40:13 -05:00
parent 9dc6c20ef8
commit 4339ffffcf
2 changed files with 14 additions and 12 deletions

View File

@@ -14,6 +14,10 @@ jest.mock("../apiClient", () => ({
$api: { $api: {
useQuery: jest.fn(), useQuery: jest.fn(),
useMutation: jest.fn(), useMutation: jest.fn(),
queryOptions: (method: string, path: string, init?: unknown) =>
init === undefined
? { queryKey: [method, path] }
: { queryKey: [method, path, init] },
}, },
API_URL: "http://test", API_URL: "http://test",
WEBSOCKET_URL: "ws://test", WEBSOCKET_URL: "ws://test",

View File

@@ -737,20 +737,18 @@ export function useRoomUpcomingMeetings(roomName: string | null) {
}); });
} }
const MEETINGS_PATH_PARTIAL = "meetings" as const; // Query keys reuse $api.queryOptions so cache identity matches the original
const MEETINGS_ACTIVE_PATH_PARTIAL = `${MEETINGS_PATH_PARTIAL}/active` as const; // per-room GET endpoints. The actual fetch goes through the batcher, but the
const MEETINGS_UPCOMING_PATH_PARTIAL = // keys stay consistent with the rest of the codebase.
`${MEETINGS_PATH_PARTIAL}/upcoming` as const; const meetingStatusKeys = {
const MEETING_LIST_PATH_PARTIALS = [
MEETINGS_ACTIVE_PATH_PARTIAL,
MEETINGS_UPCOMING_PATH_PARTIAL,
];
export const meetingStatusKeys = {
active: (roomName: string) => active: (roomName: string) =>
["rooms", roomName, MEETINGS_ACTIVE_PATH_PARTIAL] as const, $api.queryOptions("get", "/v1/rooms/{room_name}/meetings/active", {
params: { path: { room_name: roomName } },
}).queryKey,
upcoming: (roomName: string) => upcoming: (roomName: string) =>
["rooms", roomName, MEETINGS_UPCOMING_PATH_PARTIAL] as const, $api.queryOptions("get", "/v1/rooms/{room_name}/meetings/upcoming", {
params: { path: { room_name: roomName } },
}).queryKey,
}; };
export function useRoomActiveMeetings(roomName: string | null) { export function useRoomActiveMeetings(roomName: string | null) {