2018-03-03 23:15:50 +01:00
|
|
|
import { observers } from './observers/observers'
|
|
|
|
import { computations } from './computations/computations'
|
|
|
|
import { mixins } from './mixins/mixins'
|
2018-01-28 22:09:39 +01:00
|
|
|
import { LocalStorageStore } from './LocalStorageStore'
|
2018-05-01 02:20:20 +02:00
|
|
|
import { observe } from 'svelte-extras'
|
2018-01-28 22:09:39 +01:00
|
|
|
|
|
|
|
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',
|
2018-03-23 04:23:00 +01:00
|
|
|
'reduceMotion',
|
2018-02-26 01:26:43 +01:00
|
|
|
'pinnedPages',
|
2018-03-03 23:15:50 +01:00
|
|
|
'composeData'
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-01 02:20:20 +02:00
|
|
|
PinaforeStore.prototype.observe = observe
|
|
|
|
|
2018-02-20 05:15:24 +01:00
|
|
|
export const store = new PinaforeStore({
|
2018-01-28 22:09:39 +01:00
|
|
|
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: {},
|
2018-03-30 10:06:17 +02:00
|
|
|
repliesShown: {},
|
2018-02-04 21:27:28 +01:00
|
|
|
autoplayGifs: false,
|
2018-02-08 07:49:50 +01:00
|
|
|
markMediaAsSensitive: false,
|
2018-03-23 04:23:00 +01:00
|
|
|
reduceMotion: false,
|
2018-02-08 18:15:25 +01:00
|
|
|
pinnedPages: {},
|
2018-02-11 19:35:25 +01:00
|
|
|
instanceLists: {},
|
2018-02-11 22:46:57 +01:00
|
|
|
pinnedStatuses: {},
|
2018-02-24 03:23:36 +01:00
|
|
|
instanceInfos: {},
|
2018-02-26 01:26:43 +01:00
|
|
|
statusModifications: {},
|
2018-03-03 19:11:32 +01:00
|
|
|
customEmoji: {},
|
2018-03-03 23:15:50 +01:00
|
|
|
composeData: {},
|
2018-03-09 03:08:14 +01:00
|
|
|
verifyCredentials: {},
|
|
|
|
online: !process.browser || navigator.onLine
|
2018-01-28 22:09:39 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
mixins(PinaforeStore)
|
|
|
|
computations(store)
|
2018-02-21 06:29:59 +01:00
|
|
|
observers(store)
|
2018-01-28 22:09:39 +01:00
|
|
|
|
2018-02-20 05:15:24 +01:00
|
|
|
if (process.browser && process.env.NODE_ENV !== 'production') {
|
|
|
|
window.store = store // for debugging
|
2018-02-20 05:28:31 +01:00
|
|
|
}
|