2022-08-08 11:06:29 +00:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2020-04-16 11:26:44 +00:00
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
import {
|
|
|
|
SET_EVERYONE_ENABLED_E2EE,
|
|
|
|
SET_EVERYONE_SUPPORT_E2EE,
|
2021-09-21 11:00:23 +00:00
|
|
|
SET_MAX_MODE,
|
2021-07-09 12:36:19 +00:00
|
|
|
TOGGLE_E2EE
|
|
|
|
} from './actionTypes';
|
2021-09-21 11:00:23 +00:00
|
|
|
import { MAX_MODE } from './constants';
|
2020-04-16 11:26:44 +00:00
|
|
|
|
|
|
|
const DEFAULT_STATE = {
|
2021-09-21 11:00:23 +00:00
|
|
|
enabled: false,
|
|
|
|
maxMode: MAX_MODE.DISABLED
|
2020-04-16 11:26:44 +00:00
|
|
|
};
|
|
|
|
|
2022-08-08 11:06:29 +00:00
|
|
|
export interface IE2EEState {
|
|
|
|
enabled: boolean;
|
|
|
|
everyoneEnabledE2EE?: boolean;
|
|
|
|
everyoneSupportE2EE?: boolean;
|
|
|
|
maxMode: string;
|
|
|
|
}
|
|
|
|
|
2022-12-06 17:29:33 +00:00
|
|
|
export interface ISas {
|
|
|
|
emoji: Array<string>;
|
|
|
|
}
|
|
|
|
|
2020-04-16 11:26:44 +00:00
|
|
|
/**
|
|
|
|
* Reduces the Redux actions of the feature features/e2ee.
|
|
|
|
*/
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IE2EEState>('features/e2ee', (state = DEFAULT_STATE, action): IE2EEState => {
|
2020-04-16 11:26:44 +00:00
|
|
|
switch (action.type) {
|
2020-05-07 09:54:02 +00:00
|
|
|
case TOGGLE_E2EE:
|
2020-04-16 11:26:44 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2020-05-07 09:54:02 +00:00
|
|
|
enabled: action.enabled
|
2020-04-16 11:26:44 +00:00
|
|
|
};
|
2021-07-09 12:36:19 +00:00
|
|
|
case SET_EVERYONE_ENABLED_E2EE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
everyoneEnabledE2EE: action.everyoneEnabledE2EE
|
|
|
|
};
|
|
|
|
case SET_EVERYONE_SUPPORT_E2EE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
everyoneSupportE2EE: action.everyoneSupportE2EE
|
|
|
|
};
|
2020-04-16 11:26:44 +00:00
|
|
|
|
2021-09-21 11:00:23 +00:00
|
|
|
case SET_MAX_MODE: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
maxMode: action.maxMode
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-16 11:26:44 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
});
|