* Remove redux-offline and configure redux-persist * Fix typo * Fix configure store * Upgrade to redux-persist 6.0.0 * Add migration from redux-persist v4 to v6 * Replace AsyncStorage with MMKVStorage to boost storage speed * Mock RNFastStorage * Fix reactions test * Fix clearing the store on logout * Remove the need for LOGOUT_SUCCESS * No need to pass persistConfig to middlewares() * Remove unused imports * Export connection Accidentally removed this export. * Add batch action name Co-Authored-By: Elias Nahum <nahumhbl@gmail.com> * Add batch action name Co-Authored-By: Elias Nahum <nahumhbl@gmail.com> * Add batch action name Co-Authored-By: Elias Nahum <nahumhbl@gmail.com> * Add batch action name Co-Authored-By: Elias Nahum <nahumhbl@gmail.com> * Fix delete post * Fix leave channel Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
31 lines
934 B
TypeScript
31 lines
934 B
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {GeneralTypes, UserTypes} from '@mm-redux/action_types';
|
|
import {GenericAction} from '@mm-redux/types/actions';
|
|
|
|
function getInitialState() {
|
|
return {
|
|
connected: false,
|
|
lastConnectAt: 0,
|
|
lastDisconnectAt: 0,
|
|
};
|
|
}
|
|
|
|
export default function(state = getInitialState(), action: GenericAction) {
|
|
if (!state.connected && action.type === GeneralTypes.WEBSOCKET_SUCCESS) {
|
|
return {
|
|
...state,
|
|
connected: true,
|
|
lastConnectAt: action.timestamp,
|
|
};
|
|
} else if (state.connected && (action.type === GeneralTypes.WEBSOCKET_FAILURE || action.type === GeneralTypes.WEBSOCKET_CLOSED)) {
|
|
return {
|
|
...state,
|
|
connected: false,
|
|
lastDisconnectAt: action.timestamp,
|
|
};
|
|
}
|
|
|
|
return state;
|
|
}
|