mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-25 01:24:05 +02:00
Keep track of the initial hash parameters through multiple loads of the UI (close #7504)
This commit is contained in:
@@ -185,12 +185,6 @@ export function behaviorHash(context) {
|
||||
//}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ export function coreContext() {
|
||||
context.version = '2.17.2';
|
||||
context.privacyVersion = '20200407';
|
||||
|
||||
// iD will alter the hash so cache the parameters intended to setup the session
|
||||
context.initialHashParams = window.location.hash ? utilStringQs(window.location.hash) : {};
|
||||
|
||||
context.isFirstSession = !prefs('sawSplash') && !prefs('sawPrivacyVersion');
|
||||
|
||||
|
||||
@@ -455,10 +458,8 @@ export function coreContext() {
|
||||
// might matter if dependents make calls to each other. Be wary of async calls.
|
||||
function initializeDependents() {
|
||||
|
||||
const hash = utilStringQs(window.location.hash);
|
||||
|
||||
if (hash.presets) {
|
||||
presetManager.addablePresetIDs(new Set(hash.presets.split(',')));
|
||||
if (context.initialHashParams.presets) {
|
||||
presetManager.addablePresetIDs(new Set(context.initialHashParams.presets.split(',')));
|
||||
}
|
||||
|
||||
// kick off some async work
|
||||
@@ -477,8 +478,8 @@ export function coreContext() {
|
||||
_features.init();
|
||||
_photos.init();
|
||||
|
||||
if (services.maprules && hash.maprules) {
|
||||
d3_json(hash.maprules)
|
||||
if (services.maprules && context.initialHashParams.maprules) {
|
||||
d3_json(context.initialHashParams.maprules)
|
||||
.then(mapcss => {
|
||||
services.maprules.init();
|
||||
mapcss.forEach(mapcssSelector => services.maprules.addRule(mapcssSelector));
|
||||
|
||||
@@ -75,17 +75,16 @@ export function uiCommit(context) {
|
||||
if (!_changeset) {
|
||||
|
||||
// load in the URL hash values, if any
|
||||
var hashBehavior = context.ui().hash;
|
||||
if (hashBehavior.comment) {
|
||||
prefs('comment', hashBehavior.comment);
|
||||
if (context.initialHashParams.comment) {
|
||||
prefs('comment', context.initialHashParams.comment);
|
||||
prefs('commentDate', Date.now());
|
||||
}
|
||||
if (hashBehavior.source) {
|
||||
prefs('source', hashBehavior.source);
|
||||
if (context.initialHashParams.source) {
|
||||
prefs('source', context.initialHashParams.source);
|
||||
prefs('commentDate', Date.now());
|
||||
}
|
||||
if (hashBehavior.hashtags) {
|
||||
prefs('hashtags', hashBehavior.hashtags);
|
||||
if (context.initialHashParams.hashtags) {
|
||||
prefs('hashtags', context.initialHashParams.hashtags);
|
||||
}
|
||||
|
||||
var detected = utilDetect();
|
||||
|
||||
Reference in New Issue
Block a user