Add closed:note changeset tag for closed OSM notes

This commit is contained in:
Bryan Housel
2019-01-11 10:14:55 -05:00
parent 46dd90c5e5
commit 55a92ca79d
2 changed files with 23 additions and 7 deletions
+16 -2
View File
@@ -47,7 +47,7 @@ var oauth = osmAuth({
var _blacklists = ['.*\.google(apis)?\..*/(vt|kh)[\?/].*([xyz]=.*){3}.*'];
var _tileCache = { loaded: {}, inflight: {}, seen: {} };
var _noteCache = { loaded: {}, inflight: {}, inflightPost: {}, note: {}, rtree: rbush() };
var _noteCache = { loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: rbush() };
var _userCache = { toLoad: {}, user: {} };
var _changeset = {};
@@ -385,7 +385,7 @@ export default {
if (_changeset.inflight) abortRequest(_changeset.inflight);
_tileCache = { loaded: {}, inflight: {}, seen: {} };
_noteCache = { loaded: {}, inflight: {}, inflightPost: {}, note: {}, rtree: rbush() };
_noteCache = { loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: rbush() };
_userCache = { toLoad: {}, user: {} };
_changeset = {};
@@ -956,6 +956,13 @@ export default {
// we get the updated note back, remove from caches and reparse..
this.removeNote(note);
// update closed note cache - used to populate `closed:note` changeset tag
if (action === 'close') {
_noteCache.closed[note.id] = true;
} else if (action === 'reopen') {
delete _noteCache.closed[note.id];
}
var options = { skipSeen: false };
return parseXML(xml, function(err, results) {
if (err) {
@@ -1118,6 +1125,13 @@ export default {
_noteCache.note[note.id] = note;
updateRtree(encodeNoteRtree(note), true); // true = replace
return note;
},
// Get an array of note IDs closed during this session.
// Used to populate `closed:note` changeset tag
getClosedIDs: function() {
return Object.keys(_noteCache.closed).sort();
}
};
+7 -5
View File
@@ -64,6 +64,8 @@ export function uiCommit(context) {
}
var tags;
// Initialize changeset if one does not exist yet.
// Also pull values from local storage.
if (!_changeset) {
var detected = utilDetect();
tags = {
@@ -82,13 +84,9 @@ export function uiCommit(context) {
tags.hashtags = hashtags;
}
// iD 2.8.1 could write a literal 'undefined' here.. see #5021
// (old source values expire after 2 days, so 'undefined' checks can go away in v2.9)
var source = context.storage('source');
if (source && source !== 'undefined') {
if (source) {
tags.source = source;
} else if (source === 'undefined') {
context.storage('source', null);
}
_changeset = new osmChangeset({ tags: tags });
@@ -101,6 +99,10 @@ export function uiCommit(context) {
tags.imagery_used = imageryUsed || 'None';
// assign tags for closed issues and notes
var osmClosed = osm.getClosedIDs();
if (osmClosed.length) {
tags['closed:note'] = osmClosed.join(';').substr(0, 255);
}
if (services.keepRight) {
var krClosed = services.keepRight.getClosedIDs();
if (krClosed.length) {