Rename storage to localStorage in context

This commit is contained in:
Chi Vinh Le
2018-02-01 13:28:28 +01:00
parent 118301c2b4
commit 91e08cb117
8 changed files with 46 additions and 42 deletions
@@ -7,7 +7,7 @@ import {
const STORAGE_PATH = 'talkPluginRememberSort';
export default {
init: async ({ store, pymStorage, introspection }) => {
init: async ({ store, pymLocalStorage, introspection }) => {
// TODO: workaround as this plugin is included in any target and
// embeds (e.g. admin), but should only be included inside the stream.
@@ -16,10 +16,10 @@ export default {
return;
}
// We use pymStorage instead to persist the data directly on the parent page,
// We use pymLocalStorage instead to persist the data directly on the parent page,
// in order to mitigate strict cross domain security settings.
let sort = JSON.parse(await pymStorage.getItem(STORAGE_PATH));
let sort = JSON.parse(await pymLocalStorage.getItem(STORAGE_PATH));
if (
sort &&
introspection.isValidEnumValue('SORT_ORDER', sort.sortOrder) &&
@@ -35,7 +35,7 @@ export default {
// Save sorting choice to storage if it has changed.
if (!sort || sort.sortOrder !== sortOrder || sort.sortBy !== sortBy) {
sort = { sortOrder, sortBy };
pymStorage.setItem(STORAGE_PATH, JSON.stringify(sort));
pymLocalStorage.setItem(STORAGE_PATH, JSON.stringify(sort));
}
});
},