Don't reuse changeset comment, sources, and hashtags from prior uploads (close #6642, re: #6279)

This commit is contained in:
Quincy Morgan
2019-07-22 16:12:20 -04:00
parent 9d90cb9ce4
commit eb49a367b4
4 changed files with 35 additions and 21 deletions
+5 -13
View File
@@ -97,19 +97,11 @@ export function behaviorHash(context) {
context.zoomToEntity(q.id.split(',')[0], !q.map);
}
if (q.comment) {
context.storage('comment', q.comment);
context.storage('commentDate', Date.now());
}
if (q.source) {
context.storage('source', q.source);
context.storage('commentDate', Date.now());
}
if (q.hashtags) {
context.storage('hashtags', q.hashtags);
}
// Store these here instead of updating local storage since local
// storage could be flushed if the user discards pending changes
if (q.comment) behavior.comment = q.comment;
if (q.source) behavior.source = q.source;
if (q.hashtags) behavior.hashtags = q.hashtags;
if (q.walkthrough === 'true') {
behavior.startWalkthrough = true;
+8 -1
View File
@@ -643,7 +643,14 @@ export function coreHistory(context) {
clearSaved: function() {
context.debouncedSave.cancel();
if (lock.locked()) context.storage(getKey('saved_history'), null);
if (lock.locked()) {
context.storage(getKey('saved_history'), null);
// clear the changeset metadata associated with the saved history
context.storage('comment', null);
context.storage('hashtags', null);
context.storage('source', null);
}
return history;
},
+16 -1
View File
@@ -65,6 +65,21 @@ export function uiCommit(context) {
// Initialize changeset if one does not exist yet.
// Also pull values from local storage.
if (!_changeset) {
// load in the URL hash values, if any
var hash = context.ui().hash;
if (hash.comment) {
context.storage('comment', hash.comment);
context.storage('commentDate', Date.now());
}
if (hash.source) {
context.storage('source', hash.source);
context.storage('commentDate', Date.now());
}
if (hash.hashtags) {
context.storage('hashtags', hash.hashtags);
}
var detected = utilDetect();
tags = {
comment: context.storage('comment') || '',
@@ -94,7 +109,7 @@ export function uiCommit(context) {
if (sources.indexOf('streetlevel imagery') === -1) {
sources.push('streetlevel imagery');
}
// add the photo overlays used during editing as sources
photoOverlaysUsed.forEach(function(photoOverlay) {
if (sources.indexOf(photoOverlay) === -1) {
+6 -6
View File
@@ -221,9 +221,9 @@ export function uiInit(context) {
ui.onResize();
map.redrawEnable(true);
var hash = behaviorHash(context);
hash();
if (!hash.hadHash) {
ui.hash = behaviorHash(context);
ui.hash();
if (!ui.hash.hadHash) {
map.centerZoom([0, 0], 2);
}
@@ -291,7 +291,7 @@ export function uiInit(context) {
context.enter(modeBrowse(context));
if (!_initCounter++) {
if (!hash.startWalkthrough) {
if (!ui.hash.startWalkthrough) {
context.container()
.call(uiSplash(context))
.call(uiRestore(context));
@@ -317,8 +317,8 @@ export function uiInit(context) {
_initCounter++;
if (hash.startWalkthrough) {
hash.startWalkthrough = false;
if (ui.hash.startWalkthrough) {
ui.hash.startWalkthrough = false;
context.container().call(uiIntro(context));
}