Skip to content

Build your personal knowledge base with Trilium Notes

chore(react/collections/geomap): clean up

Elian Dorancb53ff880ded
diff --git a/apps/client/src/widgets/collections/geomap/index.tsx b/apps/client/src/widgets/collections/geomap/index.tsx
index 49677f622a..df04a12257 100644
--- a/apps/client/src/widgets/collections/geomap/index.tsx
+++ b/apps/client/src/widgets/collections/geomap/index.tsx
@@ -93,7 +93,7 @@ export default function GeoView({ note, noteIds, viewConfig, saveConfig }: ViewM
const apiRef = useRef<MapApi>(null);
useNoteTreeDrag(containerRef, async (treeData, e) => {
const api = apiRef.current;
- if (!note || !api) return;
+ if (!note || !api || isReadOnly) return;
const { noteId } = treeData[0];
diff --git a/apps/client/src/widgets/view_widgets/geo_view/editing.ts b/apps/client/src/widgets/view_widgets/geo_view/editing.ts
deleted file mode 100644
index 16d3f435d7..0000000000
--- a/apps/client/src/widgets/view_widgets/geo_view/editing.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { LatLng, LeafletMouseEvent } from "leaflet";
-import attributes from "../../../services/attributes";
-import { LOCATION_ATTRIBUTE } from "./index.js";
-import dialog from "../../../services/dialog";
-import server from "../../../services/server";
-import { t } from "../../../services/i18n";
-import type { Map } from "leaflet";
-import type { DragData } from "../../note_tree.js";
-import froca from "../../../services/froca.js";
-import branches from "../../../services/branches.js";
-
-export function setupDragging($container: JQuery<HTMLElement>, map: Map, mapNoteId: string) {
- $container.on("drop", async (e) => {
- try {
-
- } catch (e) {
- console.warn(e);
- }
- });
-}
diff --git a/apps/client/src/widgets/view_widgets/geo_view/index.ts b/apps/client/src/widgets/view_widgets/geo_view/index.ts
index 46f535afe2..4786748c2c 100644
--- a/apps/client/src/widgets/view_widgets/geo_view/index.ts
+++ b/apps/client/src/widgets/view_widgets/geo_view/index.ts
@@ -17,41 +17,7 @@ import { DEFAULT_MAP_LAYER_NAME, MAP_LAYERS } from "./map_layer.js";
export default class GeoView extends ViewMode<MapData> {
- private $root: JQuery<HTMLElement>;
- private $container!: JQuery<HTMLElement>;
- private map?: Map;
- private spacedUpdate: SpacedUpdate;
- private _state: State;
- private ignoreNextZoomEvent?: boolean;
-
- private currentMarkerData: Record<string, Marker>;
- private currentTrackData: Record<string, GPX>;
-
- constructor(args: ViewModeArgs) {
- super(args, "geoMap");
- this.$root = $(TPL);
- this.$container = this.$root.find(".geo-map-container");
- this.spacedUpdate = new SpacedUpdate(() => this.onSave(), 5_000);
-
- this.currentMarkerData = {};
- this.currentTrackData = {};
-
- args.$parent.append(this.$root);
- }
-
async #onMapInitialized() {
- const map = this.map;
- if (!map) {
- throw new Error(t("geo-map.unable-to-load-map"));
- }
-
- const isEditable = !this.isReadOnly;
-
- if (isEditable) {
- setupDragging(this.$container, map, this.parentNote.noteId);
- }
-
- this.#reloadMarkers();
if (hasTouchBar) {
map.on("zoom", () => {
@@ -64,27 +30,6 @@ export default class GeoView extends ViewMode<MapData> {
}
}
- async #reloadMarkers() {
- if (!this.map) {
- return;
- }
-
- // Delete all existing markers
- for (const marker of Object.values(this.currentMarkerData)) {
- marker.remove();
- }
-
- // Delete all existing tracks
- for (const track of Object.values(this.currentTrackData)) {
- track.remove();
- }
-
- // Add the new markers.
- this.currentMarkerData = {};
- const notes = await this.parentNote.getSubtreeNotes();
- const draggable = !this.isReadOnly;
- }
-
#changeState(newState: State) {
this._state = newState;
if (hasTouchBar) {
@@ -92,26 +37,6 @@ export default class GeoView extends ViewMode<MapData> {
}
}
- async onEntitiesReloaded({ loadResults }: EventData<"entitiesReloaded">) {
- // If any of the children branches are altered.
- if (loadResults.getBranchRows().find((branch) => branch.parentNoteId === this.parentNote.noteId)) {
- this.#reloadMarkers();
- return;
- }
-
- // If any of note has its location attribute changed.
- // TODO: Should probably filter by parent here as well.
- const attributeRows = loadResults.getAttributeRows();
- if (attributeRows.find((at) => [LOCATION_ATTRIBUTE, "color", "iconClass"].includes(at.name ?? ""))) {
- this.#reloadMarkers();
- }
-
- // Full reload if map layer is changed.
- if (loadResults.getAttributeRows().some(attr => (attr.name?.startsWith("map:") && attributes.isAffecting(attr, this.parentNote)))) {
- return true;
- }
- }
-
buildTouchBarCommand({ TouchBar }: CommandListenerData<"buildTouchBar">) {
const map = this.map;
const that = this;