E2C: Fix old snapshot showing when reconnecting (#91274)

This commit is contained in:
Josh Hunt 2024-07-31 15:40:55 +01:00 committed by GitHub
parent 24d2fad921
commit bffcb9de89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -69,7 +69,7 @@ function useGetLatestSnapshot(sessionUid?: string, page = 1) {
const [shouldPoll, setShouldPoll] = useState(false);
const listResult = useGetShapshotListQuery(sessionUid ? { uid: sessionUid } : skipToken);
const lastItem = listResult.data?.snapshots?.at(0);
const lastItem = listResult.currentData?.snapshots?.at(0);
const getSnapshotQueryArgs =
sessionUid && lastItem?.uid
@ -89,6 +89,13 @@ function useGetLatestSnapshot(sessionUid?: string, page = 1) {
return {
...snapshotResult,
// RTK Query will retain old data if a new request has been skipped.
// This meant that if you loaded a snapshot, disconnected, and then reconnected, we would
// show the old snapshot.
// This ensures that if the query has been skipped (because GetSessionList returned nothing)
// we don't return stale data
data: getSnapshotQueryArgs === skipToken ? undefined : snapshotResult.data,
error: listResult.error || snapshotResult.error,
// isSuccess and isUninitialised should always be from snapshotResult