Configure the offline support in the environment setup.

This commit is contained in:
Administrator
2019-05-06 09:04:00 +05:30
parent 9e39b09203
commit 121913369e
3 changed files with 15 additions and 6 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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 extensions options like name, actionsBlacklist, actionsCreators, serialize...
})
// Specify extensions options like name, actionsBlacklist, actionsCreators, serialize...
})
const persistOptions = {}
const persistCallback = () => {
@@ -49,9 +50,15 @@ const offlineConfig = {
persistCallback,
offlineStateLens
}
let store: Store<any> = createStore(rootReducer(history), fromJS(initialState), composeEnhancers(
applyMiddleware(logger,thunk, routerMiddleware(history), sagaMiddleware), offline(offlineConfig)
))
let store: Store<any>
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}