Skip to content

Commit 74f55fc

Browse files
committed
Removed refresh refetch
Not doing this through navigation anymore. There's a useRefetch hook instead
1 parent b1c33f9 commit 74f55fc

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

NavigationReact/src/AsyncStateNavigator.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,6 @@ class AsyncStateNavigator extends StateNavigator {
1818
this.offNavigate = stateNavigator.offNavigate.bind(stateNavigator);
1919
}
2020

21-
refresh(navigationData?: any, historyAction?: 'add' | 'replace' | 'none') {
22-
const refreshData = { ...this.stateContext.state.defaults, ...navigationData };
23-
const refreshKeys = Object.keys(refreshData);
24-
let equal = refreshKeys.length === Object.keys(this.stateContext.data).length;
25-
for (let i = 0; i < refreshKeys.length && equal; i++) {
26-
const key = refreshKeys[i];
27-
equal = equal && AsyncStateNavigator.areEqual(refreshData[key], this.stateContext.data[key]);
28-
}
29-
if (!equal)
30-
super.refresh(navigationData, historyAction);
31-
else {
32-
const { oldState, state, data, asyncData } = this.stateContext;
33-
const startTransition = React.startTransition || ((transition) => transition());
34-
startTransition(() => {
35-
this.navigationHandler.setState({ context: { ignoreCache: true, oldState, state, data, asyncData, stateNavigator: this } });
36-
});
37-
}
38-
}
39-
40-
private static areEqual(val: any, currentVal: any): boolean {
41-
if (currentVal == null)
42-
return val == null || val === '';
43-
const valType = Object.prototype.toString.call(val);
44-
if (valType !== Object.prototype.toString.call(currentVal))
45-
return false;
46-
if (valType === '[object Array]') {
47-
let active = val.length === currentVal.length;
48-
for(let i = 0; active && i < val.length; i++) {
49-
active = this.areEqual(val[i], currentVal[i]);
50-
}
51-
return active;
52-
} else {
53-
return isNaN(val) ? val === currentVal : +val === +currentVal;
54-
}
55-
}
56-
5721
navigateLink(url: string, historyAction: 'add' | 'replace' | 'none' = 'add', history = false,
5822
suspendNavigation?: (stateContext: StateContext, resumeNavigation: () => void) => void,
5923
currentContext = this.stateContext) {

0 commit comments

Comments
 (0)