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([
|
|
|
|
"currentInstance",
|
|
|
|
"currentRegisteredInstance",
|
|
|
|
"currentRegisteredInstanceName",
|
|
|
|
"instanceNameInSearch",
|
|
|
|
"instanceThemes",
|
|
|
|
"loggedInInstances",
|
2018-02-01 03:20:30 +01:00
|
|
|
"loggedInInstancesInOrder",
|
2018-02-05 17:50:08 +01:00
|
|
|
"autoplayGifs",
|
2018-02-08 07:49:50 +01:00
|
|
|
"markMediaAsSensitive",
|
|
|
|
"pinnedPages"
|
2018-01-28 22:09:39 +01:00
|
|
|
])
|
|
|
|
|
|
|
|
class PinaforeStore extends LocalStorageStore {
|
|
|
|
constructor(state) {
|
|
|
|
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: [],
|
2018-02-01 03:20:30 +01:00
|
|
|
instanceThemes: {},
|
2018-02-04 21:27:28 +01:00
|
|
|
spoilersShown: {},
|
|
|
|
sensitivesShown: {},
|
|
|
|
autoplayGifs: false,
|
2018-02-08 07:49:50 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
export { store }
|