@@ -14,7 +14,13 @@ const ERROR_TOLERANCY = 2;
1414const 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