From dffb417413919cce61c19eddebc28f4884623e4e Mon Sep 17 00:00:00 2001 From: LASER-Yi Date: Tue, 27 Jul 2021 22:52:27 +0800 Subject: [PATCH] no log: Rename fetched to dirty in OrderIdState --- frontend/src/@redux/utils/index.ts | 2 +- frontend/src/@redux/utils/mapper.ts | 8 ++++---- frontend/src/@types/basic.d.ts | 2 +- frontend/src/components/tables/AsyncPageTable.tsx | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/src/@redux/utils/index.ts b/frontend/src/@redux/utils/index.ts index 61340a902..e0e063f0d 100644 --- a/frontend/src/@redux/utils/index.ts +++ b/frontend/src/@redux/utils/index.ts @@ -4,7 +4,7 @@ export function defaultAOS(): AsyncOrderState { data: { items: [], order: [], - fetched: false, + dirty: false, }, }; } diff --git a/frontend/src/@redux/utils/mapper.ts b/frontend/src/@redux/utils/mapper.ts index 32c25b8aa..772caa39a 100644 --- a/frontend/src/@redux/utils/mapper.ts +++ b/frontend/src/@redux/utils/mapper.ts @@ -36,7 +36,7 @@ export function updateOrderIdState( return { data: { ...state.data, - fetched: true, + dirty: true, }, updating: true, }; @@ -44,7 +44,7 @@ export function updateOrderIdState( return { data: { ...state.data, - fetched: true, + dirty: true, }, updating: false, error: action.payload.item as Error, @@ -107,7 +107,7 @@ export function updateOrderIdState( return { updating: false, data: { - fetched: true, + dirty: true, items: newItems, order: newOrder, }, @@ -131,7 +131,7 @@ export function deleteOrderListItemBy( return { ...state, data: { - fetched: true, + dirty: true, items: newItems, order: newOrder, }, diff --git a/frontend/src/@types/basic.d.ts b/frontend/src/@types/basic.d.ts index c0fe42c3c..11ae9c5de 100644 --- a/frontend/src/@types/basic.d.ts +++ b/frontend/src/@types/basic.d.ts @@ -14,7 +14,7 @@ type StorageType = string | null; interface OrderIdState { items: IdState; order: (number | null)[]; - fetched: boolean; + dirty: boolean; } interface AsyncState { diff --git a/frontend/src/components/tables/AsyncPageTable.tsx b/frontend/src/components/tables/AsyncPageTable.tsx index ddd9469c3..54bb969c9 100644 --- a/frontend/src/components/tables/AsyncPageTable.tsx +++ b/frontend/src/components/tables/AsyncPageTable.tsx @@ -21,7 +21,7 @@ export default function AsyncPageTable(props: Props) { const { updating, - data: { order, items, fetched }, + data: { order, items, dirty }, } = aos; const allPlugins: PluginHook[] = [useDefaultSettings]; @@ -85,12 +85,12 @@ export default function AsyncPageTable(props: Props) { }, [pageIndex]); useEffect(() => { - const needInit = visibleItemIds.length === 0 && fetched === false; + const needFetch = visibleItemIds.length === 0 && dirty === false; const needRefresh = !visibleItemIds.every(isNonNullable); - if (needInit || needRefresh) { + if (needFetch || needRefresh) { loader(pageStart, pageSize); } - }, [visibleItemIds, pageStart, pageSize, loader, fetched]); + }, [visibleItemIds, pageStart, pageSize, loader, dirty]); const showLoading = useMemo( () =>