* MM-23490 Save state to file via async middleware vs store subscription Currently for iOS, a subset of store state is saved to an on-device file, so that the Share Extension can have access to information it needs (teams and channels) to function. This file saving would happen via a store subscription which triggers a file save for every dispatched action. By moving this logic to a middleware function, when this function gets invoked is now limited to a configurable set of action dispatches. (e.g. `LOGIN`, `CONNECTION_CHANGED`, `WEBSOCKET_SUCCESS`), etc. * MM-23493 Move app cache purge from store subscription to middleware (#4069) * MM-23493 Move app cache purge from store subscription to middleware This commit exposes persistence configuration as a static reference, so that cache purging can be invoked on demand anywhere else in the codebase. While middleware still may not be the best spot for this singular "action", existing functionality (reacting to `OFFLINE_STORE_PURGE`) is maintained. The change also removes the need for `state.views.root.purge` to exist in the state tree. * PR feedback: Inject config dependency for purging app cache Previously, `middleware` imported the config back from `store` (i.e. cyclic import). * PR feedback: No need to export config, now that it's passed as argument * Fix tests after refactoring middleware call from array -> function * PR feedback: Let parent continue to pass down initial store state
160 lines
3.7 KiB
JavaScript
160 lines
3.7 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import Config from 'assets/config.json';
|
|
|
|
const state = {
|
|
entities: {
|
|
general: {
|
|
appState: false,
|
|
credentials: {},
|
|
config: {},
|
|
dataRetentionPolicy: {},
|
|
deviceToken: '',
|
|
license: {},
|
|
serverVersion: '',
|
|
},
|
|
users: {
|
|
currentUserId: '',
|
|
mySessions: [],
|
|
myAudits: [],
|
|
profiles: {},
|
|
profilesInTeam: {},
|
|
profilesInChannel: {},
|
|
profilesNotInChannel: {},
|
|
statuses: {},
|
|
},
|
|
teams: {
|
|
currentTeamId: '',
|
|
teams: {},
|
|
myMembers: {},
|
|
membersInTeam: {},
|
|
stats: {},
|
|
},
|
|
channels: {
|
|
currentChannelId: '',
|
|
channels: {},
|
|
myMembers: {},
|
|
stats: {},
|
|
},
|
|
posts: {
|
|
posts: {},
|
|
postsInChannel: {},
|
|
postsInThread: {},
|
|
selectedPostId: '',
|
|
currentFocusedPostId: '',
|
|
},
|
|
preferences: {
|
|
myPreferences: {},
|
|
},
|
|
search: {
|
|
recent: [],
|
|
},
|
|
typing: {},
|
|
},
|
|
errors: [],
|
|
requests: {
|
|
channels: {
|
|
getChannels: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
createChannel: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
updateChannel: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
myChannels: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
},
|
|
general: {
|
|
websocket: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
},
|
|
posts: {
|
|
createPost: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
editPost: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
getPostThread: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
},
|
|
teams: {
|
|
getMyTeams: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
getTeams: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
joinTeam: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
},
|
|
users: {
|
|
login: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
logout: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
autocompleteUsers: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
updateMe: {
|
|
status: 'not_started',
|
|
error: null,
|
|
},
|
|
},
|
|
},
|
|
device: {
|
|
connection: true,
|
|
},
|
|
navigation: '',
|
|
views: {
|
|
channel: {
|
|
drafts: {},
|
|
},
|
|
i18n: {
|
|
locale: '',
|
|
},
|
|
root: {
|
|
deepLinkURL: '',
|
|
hydrationComplete: false,
|
|
},
|
|
selectServer: {
|
|
serverUrl: Config.DefaultServerUrl,
|
|
},
|
|
team: {
|
|
lastTeamId: '',
|
|
},
|
|
thread: {
|
|
drafts: {},
|
|
},
|
|
},
|
|
websocket: {
|
|
connected: false,
|
|
lastConnectAt: 0,
|
|
lastDisconnectAt: 0,
|
|
},
|
|
};
|
|
|
|
export default state;
|