From 242a5765485abb30e947c6cd1bb644cabbfb0b0f Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 7 Jul 2025 19:15:38 +0300 Subject: [PATCH] refactor(views/geomap): solve type errors --- .../view_widgets/geo_view/context_menu.ts | 16 +++++++--------- .../src/widgets/view_widgets/geo_view/markers.ts | 6 ++++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/client/src/widgets/view_widgets/geo_view/context_menu.ts b/apps/client/src/widgets/view_widgets/geo_view/context_menu.ts index c2b405ecf..26d91df27 100644 --- a/apps/client/src/widgets/view_widgets/geo_view/context_menu.ts +++ b/apps/client/src/widgets/view_widgets/geo_view/context_menu.ts @@ -47,7 +47,11 @@ export function openMapContextMenu(noteId: string, e: LeafletMouseEvent, isEdita items = [ ...items, { title: "----" }, - { title: t("geo-map-context.add-note"), command: "addNoteToMap", uiIcon: "bx bx-plus" } + { + title: t("geo-map-context.add-note"), + handler: () => createNewNote(noteId, e), + uiIcon: "bx bx-plus" + } ] } @@ -55,14 +59,8 @@ export function openMapContextMenu(noteId: string, e: LeafletMouseEvent, isEdita x: e.originalEvent.pageX, y: e.originalEvent.pageY, items, - selectMenuItemHandler: ({ command }) => { - switch (command) { - case "addNoteToMap": - createNewNote(noteId, e); - break; - default: - return; - } + selectMenuItemHandler: () => { + // Nothing to do, as the commands handle themselves. } }); } diff --git a/apps/client/src/widgets/view_widgets/geo_view/markers.ts b/apps/client/src/widgets/view_widgets/geo_view/markers.ts index 10a7fae65..71737df49 100644 --- a/apps/client/src/widgets/view_widgets/geo_view/markers.ts +++ b/apps/client/src/widgets/view_widgets/geo_view/markers.ts @@ -6,6 +6,8 @@ import note_tooltip from "../../../services/note_tooltip.js"; import openContextMenu from "./context_menu.js"; import server from "../../../services/server.js"; import { moveMarker } from "./editing.js"; +import appContext from "../../../components/app_context.js"; +import L from "leaflet"; let gpxLoaded = false; @@ -29,7 +31,7 @@ export default function processNoteWithMarker(map: Map, note: FNote, location: s newMarker.on("mousedown", ({ originalEvent }) => { // Middle click to open in new tab if (originalEvent.button === 1) { - const hoistedNoteId = this.hoistedNoteId; + const hoistedNoteId = appContext.tabManager.getActiveContext()?.hoistedNoteId; //@ts-ignore, fix once tab manager is ported. appContext.tabManager.openInNewTab(note.noteId, hoistedNoteId); return true; @@ -51,7 +53,7 @@ export default function processNoteWithMarker(map: Map, note: FNote, location: s export async function processNoteWithGpxTrack(map: Map, note: FNote) { if (!gpxLoaded) { - await import("leaflet-gpx"); + const GPX = await import("leaflet-gpx"); gpxLoaded = true; }