diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-01-30 12:10:10 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-01-30 16:08:08 +0100 |
commit | 0e6cb988a1cb6e0bc94053816ebb7bdc66e871af (patch) | |
tree | a7abf657c978cb6faedc918e41d3b6b8e64c26b6 /core/src/OCP | |
parent | 49ae3a3daa3ea479902386792b34359cbc8a8fdf (diff) | |
download | nextcloud-server-0e6cb988a1cb6e0bc94053816ebb7bdc66e871af.tar.gz nextcloud-server-0e6cb988a1cb6e0bc94053816ebb7bdc66e871af.zip |
Add a key parameter to the new initial state API
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'core/src/OCP')
-rw-r--r-- | core/src/OCP/index.js | 4 | ||||
-rw-r--r-- | core/src/OCP/initialstate.js | 30 |
2 files changed, 16 insertions, 18 deletions
diff --git a/core/src/OCP/index.js b/core/src/OCP/index.js index 6ec38668e72..aa3650b0614 100644 --- a/core/src/OCP/index.js +++ b/core/src/OCP/index.js @@ -3,7 +3,7 @@ */ import * as AppConfig from './appconfig' import * as Comments from './comments' -import initialState from './initialstate' +import * as InitialState from './initialstate' import Loader from './loader' import * as WhatsNew from './whatsnew' @@ -11,7 +11,7 @@ import * as WhatsNew from './whatsnew' export default { AppConfig, Comments, - InitialState: initialState, + InitialState, Loader, WhatsNew, }; diff --git a/core/src/OCP/initialstate.js b/core/src/OCP/initialstate.js index 39e913157a7..591a7e868cc 100644 --- a/core/src/OCP/initialstate.js +++ b/core/src/OCP/initialstate.js @@ -21,22 +21,20 @@ */ /** - * @namespace OCP - * @class InitialState + * @namespace OCP.InitialState */ -export default { - loadState: function(app) { - const elem = document.querySelector('#initial-state-' + app); - if (elem === null) { - console.error('Could not find initial state of ' + app); - throw new Error('Could not find initial state of ' + app); - } - try { - return JSON.parse(atob(elem.value)); - } catch (e) { - console.error('Could not parse initial state of ' + app); - throw new Error('Could not parse initial state of ' + app); - } - }, +export function loadState (app, key) { + const elem = document.querySelector(`#initial-state-${app}-${key}`); + if (elem === null) { + console.error('Could not find initial state of ' + app); + throw new Error('Could not find initial state of ' + app); + } + + try { + return JSON.parse(atob(elem.value)); + } catch (e) { + console.error('Could not parse initial state of ' + app); + throw new Error('Could not parse initial state of ' + app); + } } |