cleanup openMarkerSettings
This commit is contained in:
@@ -48,9 +48,7 @@ export const StatusToast = ({ event, t }: { event: StationStatus; t: Toast }) =>
|
||||
}, []);
|
||||
const [aircraftDataAcurate, setAircraftDataAccurate] = useState(false);
|
||||
//const mapStore = useMapStore((s) => s);
|
||||
const { openAircraftMarker, setOpenAircraftMarker, userSettings, setMap } = useMapStore(
|
||||
(store) => store,
|
||||
);
|
||||
const { setOpenAircraftMarker, setMap } = useMapStore((store) => store);
|
||||
|
||||
const { data: connectedAircrafts } = useQuery({
|
||||
queryKey: ["aircrafts"],
|
||||
@@ -132,17 +130,11 @@ export const StatusToast = ({ event, t }: { event: StationStatus; t: Toast }) =>
|
||||
className="mr-1 cursor-pointer font-bold underline"
|
||||
onClick={() => {
|
||||
if (!connectedAircraft.posLat || !connectedAircraft.posLng) return;
|
||||
if (userSettings.settingsAutoCloseMapPopup) {
|
||||
setOpenAircraftMarker({
|
||||
open: [{ id: connectedAircraft.id, tab: "fms" }],
|
||||
close: openAircraftMarker?.map((m) => m.id) || [],
|
||||
});
|
||||
} else {
|
||||
setOpenAircraftMarker({
|
||||
open: [{ id: connectedAircraft.id, tab: "fms" }],
|
||||
close: [],
|
||||
});
|
||||
}
|
||||
|
||||
setOpenAircraftMarker({
|
||||
open: [{ id: connectedAircraft.id, tab: "fms" }],
|
||||
close: [],
|
||||
});
|
||||
setMap({
|
||||
center: [connectedAircraft.posLat, connectedAircraft.posLng],
|
||||
zoom: 14,
|
||||
|
||||
@@ -250,27 +250,15 @@ const AircraftMarker = ({ aircraft }: { aircraft: ConnectedAircraft & { Station:
|
||||
close: [aircraft.id],
|
||||
});
|
||||
} else {
|
||||
if (userSettings.settingsAutoCloseMapPopup) {
|
||||
setOpenAircraftMarker({
|
||||
open: [
|
||||
{
|
||||
id: aircraft.id,
|
||||
tab: "home",
|
||||
},
|
||||
],
|
||||
close: openAircraftMarker?.map((m) => m.id) || [],
|
||||
});
|
||||
} else {
|
||||
setOpenAircraftMarker({
|
||||
open: [
|
||||
{
|
||||
id: aircraft.id,
|
||||
tab: "home",
|
||||
},
|
||||
],
|
||||
close: [],
|
||||
});
|
||||
}
|
||||
setOpenAircraftMarker({
|
||||
open: [
|
||||
{
|
||||
id: aircraft.id,
|
||||
tab: "home",
|
||||
},
|
||||
],
|
||||
close: [],
|
||||
});
|
||||
}
|
||||
};
|
||||
const marker = markerRef.current;
|
||||
|
||||
@@ -246,27 +246,15 @@ const MissionMarker = ({
|
||||
close: [mission.id],
|
||||
});
|
||||
} else {
|
||||
if (userSettings.settingsAutoCloseMapPopup) {
|
||||
setOpenMissionMarker({
|
||||
open: [
|
||||
{
|
||||
id: mission.id,
|
||||
tab: "home",
|
||||
},
|
||||
],
|
||||
close: openMissionMarker?.map((m) => m.id) || [],
|
||||
});
|
||||
} else {
|
||||
setOpenMissionMarker({
|
||||
open: [
|
||||
{
|
||||
id: mission.id,
|
||||
tab: "home",
|
||||
},
|
||||
],
|
||||
close: [],
|
||||
});
|
||||
}
|
||||
setOpenMissionMarker({
|
||||
open: [
|
||||
{
|
||||
id: mission.id,
|
||||
tab: "home",
|
||||
},
|
||||
],
|
||||
close: openMissionMarker?.map((m) => m.id) || [],
|
||||
});
|
||||
}
|
||||
};
|
||||
const markerCopy = markerRef.current;
|
||||
|
||||
@@ -48,18 +48,28 @@ export interface MapStore {
|
||||
export const useMapStore = create<MapStore>((set, get) => ({
|
||||
openMissionMarker: [],
|
||||
setOpenMissionMarker: ({ open, close }) => {
|
||||
const oldMarkers = get().openMissionMarker.filter(
|
||||
(m) => !close.includes(m.id) && !open.find((o) => o.id === m.id),
|
||||
);
|
||||
const { settingsAutoCloseMapPopup } = get().userSettings;
|
||||
|
||||
const oldMarkers =
|
||||
settingsAutoCloseMapPopup && open.length > 0
|
||||
? [] // If auto-close is enabled and opening a new popup, close all others
|
||||
: get().openMissionMarker.filter(
|
||||
(m) => !close.includes(m.id) && !open.find((o) => o.id === m.id),
|
||||
);
|
||||
set(() => ({
|
||||
openMissionMarker: [...oldMarkers, ...open],
|
||||
}));
|
||||
},
|
||||
openAircraftMarker: [],
|
||||
setOpenAircraftMarker: ({ open, close }) => {
|
||||
const oldMarkers = get().openAircraftMarker.filter(
|
||||
(m) => !close.includes(m.id) && !open.find((o) => o.id === m.id),
|
||||
);
|
||||
const { settingsAutoCloseMapPopup } = get().userSettings;
|
||||
|
||||
const oldMarkers =
|
||||
settingsAutoCloseMapPopup && open.length > 0
|
||||
? [] // If auto-close is enabled and opening a new popup, close all others
|
||||
: get().openAircraftMarker.filter(
|
||||
(m) => !close.includes(m.id) && !open.find((o) => o.id === m.id),
|
||||
);
|
||||
set(() => ({
|
||||
openAircraftMarker: [...oldMarkers, ...open],
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user