Mirror navigator online flag in observable state
This commit is contained in:
@@ -18,7 +18,8 @@ export interface State {
|
||||
routeLoading:boolean,
|
||||
menuVisible: boolean,
|
||||
userPackages: IPackages,
|
||||
accountMenuVisible: boolean
|
||||
accountMenuVisible: boolean,
|
||||
isOnline: boolean
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
@@ -31,7 +32,8 @@ export const initialState: State = {
|
||||
routeLoading: false,
|
||||
menuVisible: false,
|
||||
userPackages: {},
|
||||
accountMenuVisible: false
|
||||
accountMenuVisible: false,
|
||||
isOnline: window.navigator.onLine
|
||||
}
|
||||
|
||||
export function reducer(state = initialState, action: appCommonActions.Actions ): State {
|
||||
@@ -112,6 +114,12 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
||||
case appCommonActions.CLOSEALL: {
|
||||
return tassign(state,{accountMenuVisible:false,menuVisible:false });
|
||||
}
|
||||
case appCommonActions.ONLINE:{
|
||||
return tassign(state,{isOnline:true});
|
||||
}
|
||||
case appCommonActions.OFFLINE:{
|
||||
return tassign(state,{isOnline:false});
|
||||
}
|
||||
default: {
|
||||
return state;
|
||||
}
|
||||
@@ -128,6 +136,7 @@ export const getMenuVisible = (state: State) => state.menuVisible;
|
||||
export const getUser = (state: State) => state.user;
|
||||
export const getUserPackages = (state: State) => state.userPackages;
|
||||
export const getAccountMenuVisible = (state: State) => state.accountMenuVisible;
|
||||
export const getIsOnline = (state: State) => state.isOnline;
|
||||
|
||||
export const selectAppCommonState = createFeatureSelector<State>(MODULE_NAME);
|
||||
|
||||
@@ -141,4 +150,5 @@ export const SelectGetMenuVisible = createSelector(selectAppCommonState,getMenuV
|
||||
export const SelectGetUser = createSelector(selectAppCommonState,getUser);
|
||||
export const SelectGetUserPackages = createSelector(selectAppCommonState,getUserPackages);
|
||||
export const SelectGetAccountMenuVisible = createSelector(selectAppCommonState,getAccountMenuVisible);
|
||||
export const SelectGetIsOnline = createSelector(selectAppCommonState,getIsOnline);
|
||||
|
||||
|
Reference in New Issue
Block a user