Shared controller at current implementation commit 93ea6fee4.After
packages/widgets/src/components/schedule-explorer-controller.ts:199-276
const requestKey = useMemo(
() => JSON.stringify([
apiUrl, brandId, weekKey, filterSessionType, filterClassId,
filterInstructorId, filterLocationId, scheduleReloadToken,
]),
[apiUrl, brandId, weekKey, filterSessionType, filterClassId,
filterInstructorId, filterLocationId, scheduleReloadToken],
);
const filterContextKey = useMemo(
() => JSON.stringify([
apiUrl, brandId, filterSessionType, filterClassId,
filterInstructorId, filterLocationId, chosenCategory,
]),
[apiUrl, brandId, filterSessionType, filterClassId,
filterInstructorId, filterLocationId, chosenCategory],
);
const responseOwnsRequest = loadedRequestKey === requestKey;
const nextSearch: NextAvailableState =
search.status === "searching" && search.contextKey === filterContextKey
? "searching"
: search.status === "exhausted" &&
search.contextKey === filterContextKey &&
search.requestKey === requestKey &&
responseOwnsRequest &&
!loading
? "exhausted"
: "idle";