mirror of
https://github.com/nolanlawson/pinafore
synced 2024-12-12 18:28:03 +01:00
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
import { observers } from './observers/observers'
|
|
import { computations } from './computations/computations'
|
|
import { mixins } from './mixins/mixins'
|
|
import { LocalStorageStore } from './LocalStorageStore'
|
|
|
|
const KEYS_TO_STORE_IN_LOCAL_STORAGE = new Set([
|
|
'currentInstance',
|
|
'currentRegisteredInstance',
|
|
'currentRegisteredInstanceName',
|
|
'instanceNameInSearch',
|
|
'instanceThemes',
|
|
'loggedInInstances',
|
|
'loggedInInstancesInOrder',
|
|
'autoplayGifs',
|
|
'markMediaAsSensitive',
|
|
'pinnedPages',
|
|
'composeData'
|
|
])
|
|
|
|
class PinaforeStore extends LocalStorageStore {
|
|
constructor (state) {
|
|
super(state, KEYS_TO_STORE_IN_LOCAL_STORAGE)
|
|
}
|
|
}
|
|
|
|
export const store = new PinaforeStore({
|
|
instanceNameInSearch: '',
|
|
queryInSearch: '',
|
|
currentInstance: null,
|
|
loggedInInstances: {},
|
|
loggedInInstancesInOrder: [],
|
|
instanceThemes: {},
|
|
spoilersShown: {},
|
|
sensitivesShown: {},
|
|
autoplayGifs: false,
|
|
markMediaAsSensitive: false,
|
|
pinnedPages: {},
|
|
instanceLists: {},
|
|
pinnedStatuses: {},
|
|
instanceInfos: {},
|
|
statusModifications: {},
|
|
customEmoji: {},
|
|
composeData: {},
|
|
verifyCredentials: {}
|
|
})
|
|
|
|
mixins(PinaforeStore)
|
|
computations(store)
|
|
observers(store)
|
|
|
|
if (process.browser && process.env.NODE_ENV !== 'production') {
|
|
window.store = store // for debugging
|
|
}
|