mattermost-mobile/app/store/middlewares/index.ts
Elias Nahum 0e2bc65d70
MM-23848 consolidate store, upgrade mmkv and fix logout (#4145)
* MM-23848 consolidate store, upgrade mmkv and fix logout

* Feedback review

* Add store.ts to modulesPath
2020-04-18 10:18:24 -04:00

35 lines
No EOL
1 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Platform} from 'react-native';
import {PERSIST, REHYDRATE} from 'redux-persist';
import {ThunkMiddleware} from 'redux-thunk';
import createActionBuffer from 'redux-action-buffer';
import messageRetention from './message_retention';
import createSentryMiddleware from './sentry';
import thunk from './thunk';
export function createMiddlewares(clientOptions: any): ThunkMiddleware[] {
const {
enableBuffer,
enableThunk,
} = clientOptions;
const middleware: ThunkMiddleware[] = [];
if (enableThunk) {
middleware.push(thunk);
}
middleware.push(createSentryMiddleware(), messageRetention);
if (Platform.OS === 'ios') {
const iosExtension = require('./ios_extension').default;
middleware.push(iosExtension);
}
if (enableBuffer) {
middleware.push(createActionBuffer({breaker: REHYDRATE, passthrough: [PERSIST]}));
}
return middleware;
}