Skip to content

Build your personal knowledge base with Trilium Notes

refactor(views/geomap): solve type errors

Elian Doran242a5765485a
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 c2b405ecf4..26d91df27c 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 10a7fae654..71737df49b 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;
}