Skip to content

Commit

Permalink
feat: Added new reducer & selectors to handle the new "Always start a…
Browse files Browse the repository at this point in the history
…t home page" setting (RocketChat#2532)
  • Loading branch information
preeesha committed Jan 6, 2024
1 parent 47c02c8 commit e417d43
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/app/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) =>
Expand Down
4 changes: 3 additions & 1 deletion src/store/rootReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -69,6 +70,7 @@ export const rootReducer = combineReducers({
trustedCertificates,
notTrustedCertificates,
updateError,
doAlwaysStartAtHomePage,
isReportEnabled,
isFlashFrameEnabled,
isHardwareAccelerationEnabled,
Expand Down
24 changes: 24 additions & 0 deletions src/ui/reducers/doAlwaysStartAtHomePage.ts
Original file line number Diff line number Diff line change
@@ -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<typeof APP_SETTINGS_LOADED>
> = (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;
}
};

0 comments on commit e417d43

Please sign in to comment.