Skip to content

Commit

Permalink
Merge branch 'marker-performance-56'
Browse files Browse the repository at this point in the history
  • Loading branch information
chmac committed Feb 12, 2025
2 parents f9f393c + 2705d8e commit 3993036
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions nr-app/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isHexKey } from "@trustroots/nr-common";

// TODO - Move these into `nr-common` (they depend on nostr-tools)

export function trustrootsMapFilter(): Filter {
export function getTrustrootsMapFilter(): Filter {
const filter = {
kinds: [30398],
authors: [NOSTROOTS_VALIDATION_PUBKEY],
Expand Down Expand Up @@ -36,7 +36,7 @@ export function addOpenLocationCodePrefixToFilter(
export function trustrootsMapFilterForPlusCodePrefixes(
plusCodePrefixes: string[],
): Filter {
const baseFilter = trustrootsMapFilter();
const baseFilter = getTrustrootsMapFilter();
const filter = addOpenLocationCodePrefixToFilter(
baseFilter,
plusCodePrefixes,
Expand Down
7 changes: 5 additions & 2 deletions nr-app/src/components/MapMarkers.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { filterForMapLayerConfig, trustrootsMapFilter } from "@/common/utils";
import {
filterForMapLayerConfig,
getTrustrootsMapFilter,
} from "@/common/utils";
import { setVisiblePlusCodes } from "@/redux/actions/map.actions";
import { useAppDispatch, useAppSelector } from "@/redux/hooks";
import {
Expand Down Expand Up @@ -27,7 +30,7 @@ const selectEventsForLayers = createSelector(
[eventsSelectors.selectAll, mapSelectors.selectEnabledLayerKeys],
(allEvents, activeLayers) => {
const trustrootsEvents = allEvents.filter((event) =>
matchFilter(trustrootsMapFilter(), event.event),
matchFilter(getTrustrootsMapFilter(), event.event),
);
const layerEvents = activeLayers.map(
(layerKey): [MAP_LAYER_KEY, EventWithMetadata[]] => {
Expand Down
24 changes: 16 additions & 8 deletions nr-app/src/redux/slices/map.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ export const mapSlice = createSlice({
state.enabledLayers[action.payload] = true;
},
disableLayer: (state, action: PayloadAction<MAP_LAYER_KEY>) => {
// Disable uncommenting layers for now
return state;
// eslint-disable-next-line no-unreachable
state.enabledLayers[action.payload] = false;
},
toggleLayer: (state, action: PayloadAction<MAP_LAYER_KEY>) => {
// Disable uncommenting layers for now
if (state.enabledLayers[action.payload]) {
return state;
}
state.enabledLayers[action.payload] =
!state.enabledLayers[action.payload];
},
Expand All @@ -59,14 +66,15 @@ export const mapSlice = createSlice({
},
},
extraReducers: (builder) => {
builder.addCase(setVisiblePlusCodes, (state, action) => {
state.visiblePlusCodes = action.payload;
});
builder.addCase(setSubscriptionHasSeenEOSE, (state, action) => {
if (action.payload.id === MAP_SUBSCRIPTION_ID) {
state.mapSubscriptionIsUpdating = false;
}
});
builder
.addCase(setVisiblePlusCodes, (state, action) => {
state.visiblePlusCodes = action.payload;
})
.addCase(setSubscriptionHasSeenEOSE, (state, action) => {
if (action.payload.id === MAP_SUBSCRIPTION_ID) {
state.mapSubscriptionIsUpdating = false;
}
});
},
selectors: {
selectVisiblePlusCodes: (state) => state.visiblePlusCodes,
Expand Down

0 comments on commit 3993036

Please sign in to comment.