diff --git a/Logic/Actors/SelectedElementTagsUpdater.ts b/Logic/Actors/SelectedElementTagsUpdater.ts index 1a47b6af5f..2aa2c942ef 100644 --- a/Logic/Actors/SelectedElementTagsUpdater.ts +++ b/Logic/Actors/SelectedElementTagsUpdater.ts @@ -80,7 +80,7 @@ export default class SelectedElementTagsUpdater { ) { try { - const leftRightSensitive = state.layoutToUse.layers.some(layer => layer.lineRendering.some(lr => lr.leftRightSensitive)) + const leftRightSensitive = state.layoutToUse.isLeftRightSensitive() if (leftRightSensitive) { SimpleMetaTagger.removeBothTagging(latestTags) diff --git a/Logic/Osm/Changes.ts b/Logic/Osm/Changes.ts index 7faa234947..f176977705 100644 --- a/Logic/Osm/Changes.ts +++ b/Logic/Osm/Changes.ts @@ -6,6 +6,7 @@ import OsmChangeAction from "./Actions/OsmChangeAction"; import {ChangeDescription} from "./Actions/ChangeDescription"; import {Utils} from "../../Utils"; import {LocalStorageSource} from "../Web/LocalStorageSource"; +import SimpleMetaTagger from "../SimpleMetaTagger"; /** * Handles all changes made to OSM. @@ -26,8 +27,10 @@ export class Changes { private readonly isUploading = new UIEventSource(false); private readonly previouslyCreated: OsmObject[] = [] + private readonly _leftRightSensitive: boolean; - constructor() { + constructor(leftRightSensitive : boolean = false) { + this._leftRightSensitive = leftRightSensitive; // We keep track of all changes just as well this.allChanges.setData([...this.pendingChanges.data]) // If a pending change contains a negative ID, we save that @@ -121,6 +124,11 @@ export class Changes { const self = this; const neededIds = Changes.GetNeededIds(pending) const osmObjects = await Promise.all(neededIds.map(id => OsmObject.DownloadObjectAsync(id))); + + if(this._leftRightSensitive){ + osmObjects.forEach(obj => SimpleMetaTagger.removeBothTagging(obj.tags)) + } + console.log("Got the fresh objects!", osmObjects, "pending: ", pending) const changes: { newObjects: OsmObject[], diff --git a/Logic/State/ElementsState.ts b/Logic/State/ElementsState.ts index 241badaa2b..a4674430b0 100644 --- a/Logic/State/ElementsState.ts +++ b/Logic/State/ElementsState.ts @@ -15,7 +15,7 @@ import TitleHandler from "../Actors/TitleHandler"; /** * The part of the state keeping track of where the elements, loading them, configuring the feature pipeline etc */ -export default class ElementsState extends FeatureSwitchState{ +export default class ElementsState extends FeatureSwitchState { /** The mapping from id -> UIEventSource @@ -24,7 +24,7 @@ export default class ElementsState extends FeatureSwitchState{ /** THe change handler */ - public changes: Changes = new Changes(); + public changes: Changes; /** The latest element that was selected @@ -34,7 +34,7 @@ export default class ElementsState extends FeatureSwitchState{ "Selected element" ); - + /** * The map location: currently centered lat, lon and zoom */ @@ -48,6 +48,9 @@ export default class ElementsState extends FeatureSwitchState{ constructor(layoutToUse: LayoutConfig) { super(layoutToUse); + + this.changes = new Changes(layoutToUse.isLeftRightSensitive()) + { // -- Location control initialization const zoom = UIEventSource.asFloat( @@ -84,10 +87,10 @@ export default class ElementsState extends FeatureSwitchState{ lon.setData(latlonz.lon); }); } - + new ChangeToElementsActor(this.changes, this.allElements) new PendingChangesUploader(this.changes, this.selectedElement); new TitleHandler(this); - + } } \ No newline at end of file diff --git a/Models/ThemeConfig/LayerConfig.ts b/Models/ThemeConfig/LayerConfig.ts index 566c55dfa8..f9888f9b0a 100644 --- a/Models/ThemeConfig/LayerConfig.ts +++ b/Models/ThemeConfig/LayerConfig.ts @@ -297,4 +297,8 @@ export default class LayerConfig extends WithContextLoader{ return allIcons; } + + public isLeftRightSensitive() : boolean{ + return this.lineRendering.some(lr => lr.leftRightSensitive) + } } \ No newline at end of file diff --git a/Models/ThemeConfig/LayoutConfig.ts b/Models/ThemeConfig/LayoutConfig.ts index 56d169fc54..fc125b1544 100644 --- a/Models/ThemeConfig/LayoutConfig.ts +++ b/Models/ThemeConfig/LayoutConfig.ts @@ -279,5 +279,9 @@ export default class LayoutConfig { }) return new LayoutConfig(JSON.parse(originalJson), false, "Layout rewriting") } + + public isLeftRightSensitive(){ + return this.layers.some(l => l.isLeftRightSensitive()) + } } \ No newline at end of file diff --git a/UI/Popup/TagRenderingQuestion.ts b/UI/Popup/TagRenderingQuestion.ts index 556635c571..00f572b3d5 100644 --- a/UI/Popup/TagRenderingQuestion.ts +++ b/UI/Popup/TagRenderingQuestion.ts @@ -9,7 +9,6 @@ import CheckBoxes from "../Input/Checkboxes"; import InputElementMap from "../Input/InputElementMap"; import {SaveButton} from "./SaveButton"; import State from "../../State"; -import {Changes} from "../../Logic/Osm/Changes"; import {VariableUiElement} from "../Base/VariableUIElement"; import Translations from "../i18n/Translations"; import {FixedUiElement} from "../Base/FixedUiElement"; @@ -84,7 +83,7 @@ export default class TagRenderingQuestion extends Combine { const save = () => { const selection = inputElement.GetValue().data; if (selection) { - (State.state?.changes ?? new Changes()) + (State.state?.changes) .applyAction(new ChangeTagAction( tags.data.id, selection, tags.data, { theme: State.state?.layoutToUse?.id ?? "unkown",