From 121913369eab1a3864767976648db32d6fa90e85 Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 6 May 2019 09:04:00 +0530 Subject: [PATCH] Configure the offline support in the environment setup. --- src/config/environment.dev.ts | 1 + src/config/environment.prod.ts | 1 + src/store/configureStore.dev.ts | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/config/environment.dev.ts b/src/config/environment.dev.ts index 281fe4b..931d1ed 100644 --- a/src/config/environment.dev.ts +++ b/src/config/environment.dev.ts @@ -11,6 +11,7 @@ export const environment = { }, settings: { enabledOAuthLogin: true, + enabledOffline: true, appName: 'Green', defaultProfileCover: 'https://firebasestorage.googleapis.com/v0/b/open-social-33d92.appspot.com/o/images%2F751145a1-9488-46fd-a97e-04018665a6d3.JPG?alt=media&token=1a1d5e21-5101-450e-9054-ea4a20e06c57', defaultLanguage: LanguageType.English diff --git a/src/config/environment.prod.ts b/src/config/environment.prod.ts index 281fe4b..931d1ed 100644 --- a/src/config/environment.prod.ts +++ b/src/config/environment.prod.ts @@ -11,6 +11,7 @@ export const environment = { }, settings: { enabledOAuthLogin: true, + enabledOffline: true, appName: 'Green', defaultProfileCover: 'https://firebasestorage.googleapis.com/v0/b/open-social-33d92.appspot.com/o/images%2F751145a1-9488-46fd-a97e-04018665a6d3.JPG?alt=media&token=1a1d5e21-5101-450e-9054-ea4a20e06c57', defaultLanguage: LanguageType.English diff --git a/src/store/configureStore.dev.ts b/src/store/configureStore.dev.ts index 7eb09e4..defd7de 100644 --- a/src/store/configureStore.dev.ts +++ b/src/store/configureStore.dev.ts @@ -14,6 +14,7 @@ import defaultConfig from '@redux-offline/redux-offline/lib/defaults' // replacing redux-offline defaults with immutable* counterparts import { persist, persistAutoRehydrate, offlineStateLens } from 'redux-offline-immutable-config' +import config from 'src/config' // Create a history of your choosing (we're using a browser history in this case) export const history = createHistory() @@ -33,8 +34,8 @@ let initialState = { // - Config and create store of redux const composeEnhancers = composeWithDevTools({ - // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize... - }) + // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize... +}) const persistOptions = {} const persistCallback = () => { @@ -49,9 +50,15 @@ const offlineConfig = { persistCallback, offlineStateLens } - -let store: Store = createStore(rootReducer(history), fromJS(initialState), composeEnhancers( - applyMiddleware(logger,thunk, routerMiddleware(history), sagaMiddleware), offline(offlineConfig) -)) +let store: Store +if (config.settings.enabledOffline) { + store = createStore(rootReducer(history), fromJS(initialState), composeEnhancers( + applyMiddleware(logger,thunk, routerMiddleware(history), sagaMiddleware), offline(offlineConfig) + )) +} else { + store = createStore(rootReducer(history), fromJS(initialState), composeEnhancers( + applyMiddleware(logger,thunk, routerMiddleware(history), sagaMiddleware) + )) +} export default {store, runSaga: sagaMiddleware.run, close: () => store.dispatch(END), history}