From 930e865b42c3ccc6524ad4b2360c609c8a608869 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sat, 11 Aug 2018 19:15:18 -0400 Subject: [PATCH] Attempt to prevent users from uploading duplicate changes (closes #5200) This removes a users changes stored in localStorage if they try to close iD while an upload is in progress. It prevents the possiblity that the changeset is eventually accepted and closed, but the user can be prompted to restore those changes the next time they start iD. --- modules/core/context.js | 7 +++++++ modules/services/osm.js | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/modules/core/context.js b/modules/core/context.js index ad03eef3f2..bb127b6d9f 100644 --- a/modules/core/context.js +++ b/modules/core/context.js @@ -201,6 +201,13 @@ export function coreContext() { var canSave; if (mode && mode.id === 'save') { canSave = false; + + // Attempt to prevent user from creating duplicate changes - see #5200 + if (services.osm && services.osm.isChangesetInflight()) { + history.clearSaved(); + return; + } + } else { canSave = context.selectedIDs().every(function(id) { var entity = context.hasEntity(id); diff --git a/modules/services/osm.js b/modules/services/osm.js index 3b5121536a..7579b6051c 100644 --- a/modules/services/osm.js +++ b/modules/services/osm.js @@ -985,6 +985,11 @@ export default { }, + isChangesetInflight: function() { + return !!_changeset.inflight; + }, + + // get/set cached data // This is used to save/restore the state when entering/exiting the walkthrough // Also used for testing purposes.