forked from MapComplete/MapComplete
Detect an element that is deleted upstream; show 'this element is deleted in infopanel'
This commit is contained in:
parent
c9f6b93add
commit
5e1b4d95ab
3 changed files with 41 additions and 11 deletions
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* This actor will download the latest version of the selected element from OSM and update the tags if necessary.
|
||||
*/
|
||||
import { UIEventSource } from "../UIEventSource"
|
||||
import { ElementStorage } from "../ElementStorage"
|
||||
import { Changes } from "../Osm/Changes"
|
||||
import { OsmObject } from "../Osm/OsmObject"
|
||||
import { OsmConnection } from "../Osm/OsmConnection"
|
||||
import {UIEventSource} from "../UIEventSource"
|
||||
import {ElementStorage} from "../ElementStorage"
|
||||
import {Changes} from "../Osm/Changes"
|
||||
import {OsmObject} from "../Osm/OsmObject"
|
||||
import {OsmConnection} from "../Osm/OsmConnection"
|
||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"
|
||||
import SimpleMetaTagger from "../SimpleMetaTagger"
|
||||
|
||||
|
@ -41,7 +41,7 @@ export default class SelectedElementTagsUpdater {
|
|||
osmConnection: OsmConnection
|
||||
layoutToUse: LayoutConfig
|
||||
}) {
|
||||
state.selectedElement.addCallbackAndRunD((s) => {
|
||||
state.selectedElement.addCallbackAndRunD(async (s) => {
|
||||
let id = s.properties?.id
|
||||
|
||||
const backendUrl = state.osmConnection._oauth_config.url
|
||||
|
@ -58,9 +58,24 @@ export default class SelectedElementTagsUpdater {
|
|||
// This is a new object
|
||||
return
|
||||
}
|
||||
OsmObject.DownloadPropertiesOf(id).then((latestTags) => {
|
||||
try {
|
||||
|
||||
const latestTags = await OsmObject.DownloadPropertiesOf(id)
|
||||
if (latestTags === "deleted") {
|
||||
console.warn("The current selected element has been deleted upstream!")
|
||||
const currentTagsSource = state.allElements.getEventSourceById(id)
|
||||
if(currentTagsSource.data["_deleted"] === "yes"){
|
||||
return
|
||||
}
|
||||
currentTagsSource.data["_deleted"] = "yes"
|
||||
currentTagsSource.ping()
|
||||
return;
|
||||
}
|
||||
SelectedElementTagsUpdater.applyUpdate(state, latestTags, id)
|
||||
})
|
||||
console.log("Updated", id)
|
||||
} catch (e) {
|
||||
console.warn("Could not update", id, " due to", e)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue