diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-10-03 17:08:39 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-10-12 13:21:50 +0200 |
commit | c2e882134526816e224bb408e42f4953f385c917 (patch) | |
tree | 1c28c5e3bdd08dafa3369225365a1fee7dcda88b /core/src | |
parent | 7f8ff16c76ae31b0bcb2f62cc58ed89e7f2fbb22 (diff) | |
download | nextcloud-server-c2e882134526816e224bb408e42f4953f385c917.tar.gz nextcloud-server-c2e882134526816e224bb408e42f4953f385c917.zip |
Use the external initial state implementation
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/OCP/index.js | 9 | ||||
-rw-r--r-- | core/src/OCP/initialstate.js | 17 | ||||
-rw-r--r-- | core/src/login.js | 5 |
3 files changed, 12 insertions, 19 deletions
diff --git a/core/src/OCP/index.js b/core/src/OCP/index.js index 7d5edd5a9d0..3309e3fe047 100644 --- a/core/src/OCP/index.js +++ b/core/src/OCP/index.js @@ -3,8 +3,8 @@ */ import * as AppConfig from './appconfig' import * as Comments from './comments' -import * as InitialState from './initialstate' import Loader from './loader' +import { loadState } from '@nextcloud/initial-state' import Collaboration from './collaboration' import Toast from './toast' import * as WhatsNew from './whatsnew' @@ -14,7 +14,12 @@ export default { AppConfig, Collaboration, Comments, - InitialState, + InitialState: { + /** + * @deprecated 18.0.0 add https://www.npmjs.com/package/@nextcloud/initial-state to your app + */ + loadState + }, Loader, Toast, WhatsNew diff --git a/core/src/OCP/initialstate.js b/core/src/OCP/initialstate.js index 0a6f364ed00..57a1162bedb 100644 --- a/core/src/OCP/initialstate.js +++ b/core/src/OCP/initialstate.js @@ -24,19 +24,6 @@ * @namespace OCP.InitialState */ -export function loadState(app, key) { - const elem = document.querySelector(`#initial-state-${app}-${key}`) - if (elem === null) { - const msg = `Could not find initial state ${key} of ${app}` - console.debug(msg) - throw new Error(msg) - } +import { loadState as load } from '@nextcloud/initial-state' - try { - return JSON.parse(atob(elem.value)) - } catch (e) { - const msg = `Could not parse initial state ${key} of ${app}` - console.debug(msg) - throw new Error(msg) - } -} +export const loadState = load diff --git a/core/src/login.js b/core/src/login.js index 4314da7ab07..bb6426af1d4 100644 --- a/core/src/login.js +++ b/core/src/login.js @@ -19,8 +19,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -import Vue from 'vue' +import { loadState } from '@nextcloud/initial-state' import queryString from 'query-string' +import Vue from 'vue' // eslint-disable-next-line no-unused-vars import OC from './OC/index' // TODO: Not needed but L10n breaks if removed @@ -42,7 +43,7 @@ Vue.mixin(Nextcloud) const fromStateOr = (key, orValue) => { try { - return OCP.InitialState.loadState('core', key) + return loadState('core', key) } catch (e) { return orValue } |