Skip to content

Commit

Permalink
Don't reuse changeset comment, sources, and hashtags from prior uploa…
Browse files Browse the repository at this point in the history
…ds (close #6642, re: #6279)
  • Loading branch information
quincylvania committed Jul 22, 2019
1 parent 9d90cb9 commit eb49a36
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 21 deletions.
18 changes: 5 additions & 13 deletions modules/behavior/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion modules/core/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

Expand Down
17 changes: 16 additions & 1 deletion modules/ui/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') || '',
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions modules/ui/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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));
Expand All @@ -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));
}

Expand Down

0 comments on commit eb49a36

Please sign in to comment.