mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 01:41:24 -06:00
E2C: Fix old snapshot showing when reconnecting (#91274)
This commit is contained in:
parent
24d2fad921
commit
bffcb9de89
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user