Skip to content

Commit

Permalink
Fail gracefully if no saved settings. Fixes #1671 (#1672)
Browse files Browse the repository at this point in the history
  • Loading branch information
brollb authored Apr 23, 2020
1 parent 4b03ba7 commit 6d41069
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/common/viz/ConfigDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,20 @@ define([
};

ConfigDialog.prototype.getSavedConfig = async function () {
const secrets = await this.getConfigFromUserData(['Dialog', '__secrets__'], true) || {};
const publicData = await this.getConfigFromUserData(['Dialog']) || {};
return utils.deepExtend(publicData, secrets);
};

ConfigDialog.prototype.getConfigFromUserData = async function (keys, encrypted) {
const opts = {
method: 'GET',
credentials: 'same-origin'
};
let response = await fetch('/api/user/data/Dialog/__secrets__?decrypt=true', opts);
const secrets = await response.json();

response = await fetch('/api/user/data/Dialog', opts);
const publicData = await response.json();
return utils.deepExtend(publicData, secrets);
const url = `/api/user/data/${keys.map(encodeURIComponent).join('/')}`;
const queryString = encrypted ? 'decrypt=true' : '';
const response = await fetch(`${url}?${queryString}`, opts);
return response.status < 399 ? await response.json() : null;
};

ConfigDialog.prototype._getAllConfigValues = function () {
Expand Down

0 comments on commit 6d41069

Please sign in to comment.