Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INV-3686] Whats Here Offline Workflow #3752

Merged
merged 7 commits into from
Dec 17, 2024
2 changes: 1 addition & 1 deletion app/src/state/actions/whatsHere/WhatsHere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class WhatsHere {
static readonly page_activity = createAction<{ page: number; limit: number }>(`${this.PREFIX}/page_activity`);
static readonly server_filtered_ids_fetched = createAction(
`${this.PREFIX}/server_filtered_ids_fetched`,
(activities, iapp) => ({
(activities: string[], iapp: string[]) => ({
payload: { activities, iapp }
})
);
Expand Down
34 changes: 10 additions & 24 deletions app/src/state/reducers/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,34 +532,22 @@ function createMapReducer(configuration: AppConfig): (MapState, AnyAction) => Ma
} else if (WhatsHere.server_filtered_ids_fetched.match(action)) {
draftState.whatsHere.serverActivityIDs = action.payload.activities;
draftState.whatsHere.serverIAPPIDs = action.payload.iapp;

const toggledOnActivityLayers = draftState.layers.filter(
(layer) => layer.type === RecordSetType.Activity && layer.layerState.mapToggle
({ type, layerState }) => type === RecordSetType.Activity && layerState.mapToggle
);

const toggledOnIAPPLayers = draftState.layers.filter(
(layer) => layer.type === RecordSetType.IAPP && layer.layerState.mapToggle
({ type, layerState }) => type === RecordSetType.IAPP && layerState.mapToggle
);
const localActivityIDs = toggledOnActivityLayers.flatMap(
(layer) => layer.IDList ?? layer?.layerState?.cacheMetadata?.idList ?? []
);
const localIappIds = toggledOnIAPPLayers.flatMap((layer) => layer.IDList ?? layer?.cacheMetadata?.idList ?? []);
const iappIds = localIappIds.filter((l) => draftState.whatsHere.serverIAPPIDs.includes(l));
const activityIds = localActivityIDs.filter((l) => draftState.whatsHere.serverActivityIDs.includes(l));

let localActivityIDs = [];

toggledOnActivityLayers.forEach((layer) => {
localActivityIDs = localActivityIDs.concat(layer.IDList);
});

let localIAPPIDs = [];

toggledOnIAPPLayers.forEach((layer) => {
localIAPPIDs = localIAPPIDs.concat(layer.IDList);
});

const iappIDs = [];
const activityIDs = [];
localIAPPIDs.forEach((l) => draftState.whatsHere.serverIAPPIDs.includes(l) && iappIDs.push(l));
localActivityIDs.forEach((l) => draftState.whatsHere.serverActivityIDs.includes(l) && activityIDs.push(l));

draftState.whatsHere.ActivityIDs = Array.from(new Set(activityIDs));
draftState.whatsHere.IAPPIDs = Array.from(new Set(iappIDs));
draftState.whatsHere.ActivityIDs = Array.from(new Set(activityIds));
draftState.whatsHere.IAPPIDs = Array.from(new Set(iappIds));
} else if (WhatsHere.sort_filter_update.match(action)) {
if (action.payload.type === RecordSetType.IAPP) {
draftState.whatsHere.IAPPPage = 0;
Expand Down Expand Up @@ -758,8 +746,6 @@ function createMapReducer(configuration: AppConfig): (MapState, AnyAction) => Ma
if (draftState.MapMode === 'VECTOR_ENDPOINT') {
draftState.layers[index].loading = false;
}

//if (draftState.activitiesGeoJSON?.features?.length > 0) {
if (draftState.MapMode !== 'VECTOR_ENDPOINT' && draftState.activitiesGeoJSONDict !== undefined) {
GeoJSONFilterSetForLayer(
draftState,
Expand Down
Loading
Loading