Skip to content

Commit 0f88a5b

Browse files
committed
fix: add comparing entire resource
1 parent e30bee1 commit 0f88a5b

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/components/Nodes/nodeQueries.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function useNodesQuery(skip = false) {
5151
{
5252
pollingInterval: 4000,
5353
skip,
54+
compareEntireResource: true,
5455
},
5556
);
5657

src/shared/hooks/BackendAPI/useGet.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ const ERROR_TOLERANCY = 2;
1414
const useGetHook = processDataFn =>
1515
function(
1616
path,
17-
{ pollingInterval, onDataReceived, skip, errorTolerancy = undefined } = {},
17+
{
18+
pollingInterval,
19+
onDataReceived,
20+
skip,
21+
errorTolerancy = undefined,
22+
compareEntireResource = false,
23+
} = {},
1824
) {
1925
const authData = useRecoilValue(authDataState);
2026
const lastAuthData = useRef(null);
@@ -82,7 +88,13 @@ const useGetHook = processDataFn =>
8288
if (error) setTimeout(_ => setError(null)); // bring back the data and clear the error once the connection started working again
8389
errorTolerancyCounter.current = 0;
8490
setTimeout(_ =>
85-
processDataFn(payload, currentData, setData, lastResourceVersion),
91+
processDataFn(
92+
payload,
93+
currentData,
94+
setData,
95+
lastResourceVersion,
96+
compareEntireResource,
97+
),
8698
);
8799
} catch (e) {
88100
previousRequestNotFinished.current = null;
@@ -325,10 +337,17 @@ function handleListDataReceived(filter) {
325337
};
326338
}
327339

328-
function handleSingleDataReceived(newData, oldData, setDataFn) {
340+
function handleSingleDataReceived(
341+
newData,
342+
oldData,
343+
setDataFn,
344+
compareEntireResource,
345+
) {
329346
if (
330347
!oldData || // current data is empty and we received some. There's no doubdt we should update.
331-
newData.metadata.resourceVersion !== oldData.metadata?.resourceVersion
348+
newData.metadata.resourceVersion !== oldData.metadata?.resourceVersion ||
349+
(compareEntireResource &&
350+
JSON.stringify(newData) !== JSON.stringify(oldData))
332351
) {
333352
// Compare resourceVersion.
334353
setDataFn(newData);

0 commit comments

Comments
 (0)