chore(react/collections/geomap): bring back adding new items

This commit is contained in:
Elian Doran
2025-09-04 21:37:08 +03:00
parent 189b7e20db
commit 50121153dd
4 changed files with 49 additions and 45 deletions

View File

@@ -13,10 +13,7 @@ import attributes from "../../../services/attributes.js";
import { DEFAULT_MAP_LAYER_NAME, MAP_LAYERS } from "./map_layer.js";
enum State {
Normal,
NewNote
}
export default class GeoView extends ViewMode<MapData> {
@@ -38,7 +35,6 @@ export default class GeoView extends ViewMode<MapData> {
this.currentMarkerData = {};
this.currentTrackData = {};
this._state = State.Normal;
args.$parent.append(this.$root);
}
@@ -127,7 +123,6 @@ export default class GeoView extends ViewMode<MapData> {
#changeState(newState: State) {
this._state = newState;
this.$container.toggleClass("placing-note", newState === State.NewNote);
if (hasTouchBar) {
this.triggerCommand("refreshTouchBar");
}
@@ -153,39 +148,6 @@ export default class GeoView extends ViewMode<MapData> {
}
}
async geoMapCreateChildNoteEvent({ ntxId }: EventData<"geoMapCreateChildNote">) {
toast.showPersistent({
icon: "plus",
id: "geo-new-note",
title: "New note",
message: t("geo-map.create-child-note-instruction")
});
this.#changeState(State.NewNote);
const globalKeyListener: (this: Window, ev: KeyboardEvent) => any = (e) => {
if (e.key !== "Escape") {
return;
}
this.#changeState(State.Normal);
window.removeEventListener("keydown", globalKeyListener);
toast.closePersistent("geo-new-note");
};
window.addEventListener("keydown", globalKeyListener);
}
async #onMapClicked(e: LeafletMouseEvent) {
if (this._state !== State.NewNote) {
return;
}
toast.closePersistent("geo-new-note");
await createNewNote(this.parentNote.noteId, e);
this.#changeState(State.Normal);
}
deleteFromMapEvent({ noteId }: EventData<"deleteFromMap">) {
moveMarker(noteId, null);
}