Skip to content

Commit

Permalink
Avoids unnecessary pushes to the undo stack to slightly improve perfo…
Browse files Browse the repository at this point in the history
…rmance
  • Loading branch information
mthh committed Oct 8, 2024
1 parent d35e5d0 commit da5ef68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/components/MapZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
getDefaultClipExtent,
mapStore,
setMapStore,
setMapStoreBase,
} from '../store/MapStore';

// Sub-components
Expand Down Expand Up @@ -259,7 +260,7 @@ const makeMapResizable = (refMapShadow: HTMLDivElement) => {
refMapShadow.style.display = 'block';
initialShadowRect = refMapShadow.getBoundingClientRect();
currentLock = mapStore.lockZoomPan;
setMapStore('lockZoomPan', true);
setMapStoreBase('lockZoomPan', true);
},
move(event) {
// Since we are centering the map in its container, we need to
Expand Down Expand Up @@ -385,7 +386,7 @@ export default function MapZone(): JSX.Element {
});

// Update the map store with the new scale and translate
setMapStore({
setMapStoreBase({
scale: globalStore.projection.scale(),
translate: globalStore.projection.translate(),
});
Expand Down Expand Up @@ -828,7 +829,7 @@ export default function MapZone(): JSX.Element {
<button
class="button"
onClick={() => {
setMapStore({ lockZoomPan: true });
setMapStoreBase({ lockZoomPan: true });
}}
aria-label={LL().MapZone.Controls.Lock()}
title={LL().MapZone.Controls.Lock()}
Expand All @@ -839,7 +840,7 @@ export default function MapZone(): JSX.Element {
<Match when={mapStore.lockZoomPan}>
<button
class="button"
onClick={() => { setMapStore({ lockZoomPan: false }); }}
onClick={() => { setMapStoreBase({ lockZoomPan: false }); }}
aria-label={LL().MapZone.Controls.Unlock()}
title={LL().MapZone.Controls.Unlock()}
>
Expand Down
6 changes: 3 additions & 3 deletions src/store/MapStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { globalStore, setGlobalStore } from './GlobalStore';
import {
layersDescriptionStore,
LayersDescriptionStoreType,
setLayersDescriptionStore,
setLayersDescriptionStoreBase,
} from './LayersDescriptionStore';
import { applicationSettingsStore } from './ApplicationSettingsStore';

Expand Down Expand Up @@ -205,7 +205,7 @@ createEffect(
.some((l) => l.rendererParameters && l.rendererParameters.avoidOverlapping === true);

if (needToRecomputePositions) {
setLayersDescriptionStore(
setLayersDescriptionStoreBase(
produce(
(draft: LayersDescriptionStoreType) => {
// Recompute position for proportional symbols layers with the avoidOverlapping option
Expand Down Expand Up @@ -422,7 +422,7 @@ createEffect(
// 6. Update the global store with the new
// scale, translate, rotate, center, parallel and parallels values
// if they changed
setMapStore({
setMapStoreBase({
scale: projection.scale(),
translate: projection.translate(),
rotate: projection.rotate ? projection.rotate() : undefined,
Expand Down

0 comments on commit da5ef68

Please sign in to comment.