From 77ba91c7129b0f01f771b95f6ea44675c635683d Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Thu, 19 Apr 2018 21:38:11 -0700 Subject: [PATCH] fix animations and cleanup store/component get() usage (#185) fixes #181 --- routes/_components/IconButton.html | 2 +- routes/_store/LocalStorageStore.js | 2 +- routes/_store/mixins/timelineMixins.js | 6 +++--- routes/_utils/RealmStore.js | 5 ++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/routes/_components/IconButton.html b/routes/_components/IconButton.html index 3408e07..8061f87 100644 --- a/routes/_components/IconButton.html +++ b/routes/_components/IconButton.html @@ -107,7 +107,7 @@ export default { oncreate () { this.observe('animation', animation => { - let reduceMotion = this.store.get() + let { reduceMotion } = this.store.get() if (!animation || reduceMotion) { return } diff --git a/routes/_store/LocalStorageStore.js b/routes/_store/LocalStorageStore.js index 795c10f..bba6ff3 100644 --- a/routes/_store/LocalStorageStore.js +++ b/routes/_store/LocalStorageStore.js @@ -40,7 +40,7 @@ export class LocalStorageStore extends Store { return } Object.keys(this._keysToSave).forEach(key => { - LS.setItem(`store_${key}`, JSON.stringify(this.get(key))) + LS.setItem(`store_${key}`, JSON.stringify(this.get()[key])) }) this._keysToSave = {} } diff --git a/routes/_store/mixins/timelineMixins.js b/routes/_store/mixins/timelineMixins.js index 3af5eeb..75fc809 100644 --- a/routes/_store/mixins/timelineMixins.js +++ b/routes/_store/mixins/timelineMixins.js @@ -5,7 +5,7 @@ export function timelineMixins (Store) { let valuesToSet = {} for (let key of Object.keys(obj)) { let rootKey = `timelineData_${key}` - let root = this.get(rootKey) || {} + let root = this.get()[rootKey] || {} let instanceData = root[instanceName] = root[instanceName] || {} instanceData[timelineName] = obj[key] valuesToSet[rootKey] = root @@ -16,7 +16,7 @@ export function timelineMixins (Store) { Store.prototype.getForTimeline = function (instanceName, timelineName, key) { let rootKey = `timelineData_${key}` - let root = this.get(rootKey) + let root = this.get()[rootKey] return root && root[instanceName] && root[instanceName][timelineName] } @@ -26,7 +26,7 @@ export function timelineMixins (Store) { } Store.prototype.getAllTimelineData = function (instanceName, key) { - let root = this.get(`timelineData_${key}`) || {} + let root = this.get()[`timelineData_${key}`] || {} return root[instanceName] || {} } diff --git a/routes/_utils/RealmStore.js b/routes/_utils/RealmStore.js index 4934651..62302d0 100644 --- a/routes/_utils/RealmStore.js +++ b/routes/_utils/RealmStore.js @@ -17,8 +17,7 @@ export class RealmStore extends Store { } setForRealm (obj) { - let { currentRealm } = this.get() - let { realms } = this.get() + let { currentRealm, realms } = this.get() realms.set(currentRealm, Object.assign(realms.get(currentRealm) || {}, obj)) this.set({realms: realms}) } @@ -58,7 +57,7 @@ export class RealmStore extends Store { return } mark('batchUpdate') - let obj = this.get(key) + let obj = this.get()[key] for (let otherKey of updatedKeys) { obj[otherKey] = batch[otherKey] }