forked from MapComplete/MapComplete
Merge develop
This commit is contained in:
commit
c8bd412476
49 changed files with 1342 additions and 977 deletions
36
Logic/Actors/ChangeToElementsActor.ts
Normal file
36
Logic/Actors/ChangeToElementsActor.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import {ElementStorage} from "../ElementStorage";
|
||||
import {Changes} from "../Osm/Changes";
|
||||
|
||||
export default class ChangeToElementsActor {
|
||||
constructor(changes: Changes, allElements: ElementStorage) {
|
||||
changes.pendingChanges.addCallbackAndRun(changes => {
|
||||
for (const change of changes) {
|
||||
const id = change.type + "/" + change.id;
|
||||
if (!allElements.has(id)) {
|
||||
continue; // Ignored as the geometryFixer will introduce this
|
||||
}
|
||||
const src = allElements.getEventSourceById(id)
|
||||
|
||||
let changed = false;
|
||||
for (const kv of change.tags ?? []) {
|
||||
// Apply tag changes and ping the consumers
|
||||
const k = kv.k
|
||||
let v = kv.v
|
||||
if (v === "") {
|
||||
v = undefined;
|
||||
}
|
||||
if (src.data[k] === v) {
|
||||
continue
|
||||
}
|
||||
changed = true;
|
||||
src.data[k] = v;
|
||||
}
|
||||
if (changed) {
|
||||
src.ping()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ export default class PendingChangesUploader {
|
|||
constructor(changes: Changes, selectedFeature: UIEventSource<any>) {
|
||||
const self = this;
|
||||
this.lastChange = new Date();
|
||||
changes.pending.addCallback(() => {
|
||||
changes.pendingChanges.addCallback(() => {
|
||||
self.lastChange = new Date();
|
||||
|
||||
window.setTimeout(() => {
|
||||
|
|
@ -54,7 +54,7 @@ export default class PendingChangesUploader {
|
|||
|
||||
|
||||
function onunload(e) {
|
||||
if (changes.pending.data.length == 0) {
|
||||
if(changes.pendingChanges.data.length == 0){
|
||||
return;
|
||||
}
|
||||
changes.flushChanges("onbeforeunload - probably closing or something similar");
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export default class SelectedFeatureHandler {
|
|||
private readonly _hash: UIEventSource<string>;
|
||||
private readonly _selectedFeature: UIEventSource<any>;
|
||||
|
||||
private static readonly _no_trigger_on = ["welcome","copyright","layers"]
|
||||
private static readonly _no_trigger_on = ["welcome","copyright","layers","new"]
|
||||
private readonly _osmApiSource: OsmApiFeatureSource;
|
||||
|
||||
constructor(hash: UIEventSource<string>,
|
||||
|
|
@ -60,7 +60,9 @@ export default class SelectedFeatureHandler {
|
|||
if(hash === undefined || SelectedFeatureHandler._no_trigger_on.indexOf(hash) >= 0){
|
||||
return; // No valid feature selected
|
||||
}
|
||||
// We should have a valid osm-ID and zoom to it
|
||||
// We should have a valid osm-ID and zoom to it... But we wrap it in try-catch to be sure
|
||||
try{
|
||||
|
||||
OsmObject.DownloadObject(hash).addCallbackAndRunD(element => {
|
||||
const centerpoint = element.centerpoint();
|
||||
console.log("Zooming to location for select point: ", centerpoint)
|
||||
|
|
@ -68,6 +70,9 @@ export default class SelectedFeatureHandler {
|
|||
location.data.lon = centerpoint[1]
|
||||
location.ping();
|
||||
})
|
||||
}catch(e){
|
||||
console.error("Could not download OSM-object with id", hash, " - probably a weird hash")
|
||||
}
|
||||
}
|
||||
|
||||
private downloadFeature(hash: string){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue