From afcfda5bda04ca0e2be5ebf8f90bdc48dd07a9c6 Mon Sep 17 00:00:00 2001 From: ziggabyte Date: Mon, 9 Dec 2024 11:17:57 +0100 Subject: [PATCH 1/2] Set list of places as "stale" when running "sync" function. --- src/features/canvassAssignments/hooks/useSidebarStats.ts | 2 ++ src/features/canvassAssignments/store.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/features/canvassAssignments/hooks/useSidebarStats.ts b/src/features/canvassAssignments/hooks/useSidebarStats.ts index e1df050d0..c4733ae2e 100644 --- a/src/features/canvassAssignments/hooks/useSidebarStats.ts +++ b/src/features/canvassAssignments/hooks/useSidebarStats.ts @@ -1,6 +1,7 @@ import { loadListIfNecessary } from 'core/caching/cacheUtils'; import { useApiClient, useAppDispatch, useAppSelector } from 'core/hooks'; import { + placesInvalidated, placesLoad, placesLoaded, visitsInvalidated, @@ -134,6 +135,7 @@ export default function useSidebarStats( stats, sync: () => { dispatch(visitsInvalidated(assignmentId)); + dispatch(placesInvalidated); }, synced: visitList?.loaded || null, }; diff --git a/src/features/canvassAssignments/store.ts b/src/features/canvassAssignments/store.ts index c10e6097d..ec796b1d5 100644 --- a/src/features/canvassAssignments/store.ts +++ b/src/features/canvassAssignments/store.ts @@ -256,6 +256,9 @@ const canvassAssignmentSlice = createSlice({ item.data = place; item.loaded = new Date().toISOString(); }, + placesInvalidated: (state) => { + state.placeList.isStale = true; + }, placesLoad: (state) => { state.placeList.isLoading = true; }, @@ -361,6 +364,7 @@ export const { canvassSessionsLoad, canvassSessionsLoaded, placeCreated, + placesInvalidated, placesLoad, placesLoaded, placeUpdated, From 21f79c9b6b15501990a5331d9651ad5d4b30c394 Mon Sep 17 00:00:00 2001 From: ziggi <58265097+ziggabyte@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:34:36 +0100 Subject: [PATCH 2/2] Remove n00b mistake to dispatch function, not action Co-authored-by: Richard Olsson --- src/features/canvassAssignments/hooks/useSidebarStats.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/canvassAssignments/hooks/useSidebarStats.ts b/src/features/canvassAssignments/hooks/useSidebarStats.ts index c4733ae2e..1665ae348 100644 --- a/src/features/canvassAssignments/hooks/useSidebarStats.ts +++ b/src/features/canvassAssignments/hooks/useSidebarStats.ts @@ -135,7 +135,7 @@ export default function useSidebarStats( stats, sync: () => { dispatch(visitsInvalidated(assignmentId)); - dispatch(placesInvalidated); + dispatch(placesInvalidated()); }, synced: visitList?.loaded || null, };