mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -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 [shouldPoll, setShouldPoll] = useState(false);
|
||||||
|
|
||||||
const listResult = useGetShapshotListQuery(sessionUid ? { uid: sessionUid } : skipToken);
|
const listResult = useGetShapshotListQuery(sessionUid ? { uid: sessionUid } : skipToken);
|
||||||
const lastItem = listResult.data?.snapshots?.at(0);
|
const lastItem = listResult.currentData?.snapshots?.at(0);
|
||||||
|
|
||||||
const getSnapshotQueryArgs =
|
const getSnapshotQueryArgs =
|
||||||
sessionUid && lastItem?.uid
|
sessionUid && lastItem?.uid
|
||||||
@ -89,6 +89,13 @@ function useGetLatestSnapshot(sessionUid?: string, page = 1) {
|
|||||||
return {
|
return {
|
||||||
...snapshotResult,
|
...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,
|
error: listResult.error || snapshotResult.error,
|
||||||
|
|
||||||
// isSuccess and isUninitialised should always be from snapshotResult
|
// isSuccess and isUninitialised should always be from snapshotResult
|
||||||
|
Loading…
Reference in New Issue
Block a user