pinafore/routes/_store/store.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-02-08 18:15:25 +01:00
import { observers } from './observers'
2018-01-28 22:09:39 +01:00
import { computations } from './computations'
import { mixins } from './mixins'
import { LocalStorageStore } from './LocalStorageStore'
const KEYS_TO_STORE_IN_LOCAL_STORAGE = new Set([
2018-02-09 07:29:29 +01:00
'currentInstance',
'currentRegisteredInstance',
'currentRegisteredInstanceName',
'instanceNameInSearch',
'instanceThemes',
'loggedInInstances',
'loggedInInstancesInOrder',
'autoplayGifs',
'markMediaAsSensitive',
'pinnedPages'
2018-01-28 22:09:39 +01:00
])
class PinaforeStore extends LocalStorageStore {
2018-02-09 07:29:29 +01:00
constructor (state) {
2018-01-28 22:09:39 +01:00
super(state, KEYS_TO_STORE_IN_LOCAL_STORAGE)
}
}
const store = new PinaforeStore({
instanceNameInSearch: '',
2018-02-07 05:54:49 +01:00
queryInSearch: '',
2018-01-28 22:09:39 +01:00
currentInstance: null,
loggedInInstances: {},
loggedInInstancesInOrder: [],
instanceThemes: {},
spoilersShown: {},
sensitivesShown: {},
autoplayGifs: false,
markMediaAsSensitive: false,
2018-02-08 18:15:25 +01:00
pinnedPages: {},
instanceLists: {}
2018-01-28 22:09:39 +01:00
})
mixins(PinaforeStore)
computations(store)
observers(store)
if (process.browser && process.env.NODE_ENV !== 'production') {
window.store = store // for debugging
}
2018-02-09 07:29:29 +01:00
export { store }