Add cache-first service worker

This commit is contained in:
Ken-Håvard Lieng 2018-11-06 11:13:32 +01:00
parent b2b5f82486
commit ca222ff10d
20 changed files with 672 additions and 181 deletions

View file

@ -1,3 +1,4 @@
/* eslint-disable no-underscore-dangle */
import Cookie from 'js-cookie';
import { socket as socketActions } from 'state/actions';
import { getWrapWidth, setConnectDefaults, appSet } from 'state/app';
@ -8,9 +9,7 @@ import { find } from 'utils';
import { when } from 'utils/observe';
import { replace } from 'utils/router';
export default function initialState({ store }) {
const env = JSON.parse(document.getElementById('env').innerHTML);
function loadState({ store }, env) {
store.dispatch(setConnectDefaults(env.defaults));
store.dispatch(appSet('hexIP', env.hexIP));
store.dispatch(setSettings(env.settings, true));
@ -70,3 +69,12 @@ export default function initialState({ store }) {
}
});
}
export default function initialState(ctx) {
if (window.__env__) {
window.__env__.then(env => loadState(ctx, env));
} else {
const env = JSON.parse(document.getElementById('env').innerHTML);
loadState(ctx, env);
}
}