From e105b1a6d4448974dd78a5724ce20b0a0c9ab011 Mon Sep 17 00:00:00 2001 From: Prisha Gupta Date: Sat, 6 Jan 2024 20:23:47 +0530 Subject: [PATCH] feat: added new reducer & selectors to handle the new "Always start at home page" setting (#2532) --- src/app/selectors.ts | 2 ++ src/store/rootReducer.ts | 4 +++- src/ui/reducers/doAlwaysStartAtHomePage.ts | 24 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/ui/reducers/doAlwaysStartAtHomePage.ts diff --git a/src/app/selectors.ts b/src/app/selectors.ts index 8307e0826..8308a111e 100644 --- a/src/app/selectors.ts +++ b/src/app/selectors.ts @@ -32,6 +32,8 @@ export const selectPersistableValues = createStructuredSelector< allowedJitsiServers: ({ allowedJitsiServers }) => allowedJitsiServers, isReportEnabled: ({ isReportEnabled }) => isReportEnabled, isFlashFrameEnabled: ({ isFlashFrameEnabled }) => isFlashFrameEnabled, + doAlwaysStartAtHomePage: ({ doAlwaysStartAtHomePage }) => + doAlwaysStartAtHomePage, isInternalVideoChatWindowEnabled: ({ isInternalVideoChatWindowEnabled }) => isInternalVideoChatWindowEnabled, isMinimizeOnCloseEnabled: ({ isMinimizeOnCloseEnabled }) => diff --git a/src/store/rootReducer.ts b/src/store/rootReducer.ts index 580df55ca..18515459a 100644 --- a/src/store/rootReducer.ts +++ b/src/store/rootReducer.ts @@ -8,11 +8,12 @@ import { allowedJitsiServers } from '../jitsi/reducers'; import { clientCertificates, externalProtocols, - trustedCertificates, notTrustedCertificates, + trustedCertificates, } from '../navigation/reducers'; import { servers } from '../servers/reducers'; import { currentView } from '../ui/reducers/currentView'; +import { doAlwaysStartAtHomePage } from '../ui/reducers/doAlwaysStartAtHomePage'; import { hasHideOnTrayNotificationShown } from '../ui/reducers/hasHideOnTrayNotificationShown'; import { isAddNewServersEnabled } from '../ui/reducers/isAddNewServersEnabled'; import { isFlashFrameEnabled } from '../ui/reducers/isFlashFrameEnabled'; @@ -69,6 +70,7 @@ export const rootReducer = combineReducers({ trustedCertificates, notTrustedCertificates, updateError, + doAlwaysStartAtHomePage, isReportEnabled, isFlashFrameEnabled, isHardwareAccelerationEnabled, diff --git a/src/ui/reducers/doAlwaysStartAtHomePage.ts b/src/ui/reducers/doAlwaysStartAtHomePage.ts new file mode 100644 index 000000000..e1f45833c --- /dev/null +++ b/src/ui/reducers/doAlwaysStartAtHomePage.ts @@ -0,0 +1,24 @@ +import type { Reducer } from 'redux'; + +import { APP_SETTINGS_LOADED } from '../../app/actions'; +import type { ActionOf } from '../../store/actions'; +import { SETTINGS_SET_DO_ALWAYS_START_AT_HOME_PAGE_CHANGED } from '../actions'; + +type DoAlwaysStartAtHomePageEnabledAction = ActionOf< + typeof SETTINGS_SET_DO_ALWAYS_START_AT_HOME_PAGE_CHANGED +>; + +export const doAlwaysStartAtHomePage: Reducer< + boolean, + DoAlwaysStartAtHomePageEnabledAction | ActionOf +> = (state = true, action) => { + switch (action.type) { + case APP_SETTINGS_LOADED: + return Boolean(action.payload.doAlwaysStartAtHomePage); + case SETTINGS_SET_DO_ALWAYS_START_AT_HOME_PAGE_CHANGED: { + return action.payload; + } + default: + return state; + } +};