Active Sessions: Show 1 year option if set (#1985)

This commit is contained in:
Alexander Zinchuk 2022-08-05 19:23:37 +02:00
parent c738eaf13b
commit 1aec0c51ef

View File

@ -15,10 +15,10 @@ import getSessionIcon from './helpers/getSessionIcon';
import ListItem from '../../ui/ListItem';
import ConfirmDialog from '../../ui/ConfirmDialog';
import RadioGroup from '../../ui/RadioGroup';
import SettingsActiveSession from './SettingsActiveSession';
import './SettingsActiveSessions.scss';
import RadioGroup from '../../ui/RadioGroup';
type OwnProps = {
isActive?: boolean;
@ -55,23 +55,32 @@ const SettingsActiveSessions: FC<OwnProps & StateProps> = ({
if (ttlDays === undefined) {
return undefined;
}
if (ttlDays <= 7) {
return '7';
}
if (ttlDays <= 30) {
return '30';
}
if (ttlDays <= 93) {
return '90';
}
if (ttlDays <= 183) {
return '183';
}
if (ttlDays > 183) {
return '365';
}
return undefined;
}, [ttlDays]);
const AUTO_TERMINATE_OPTIONS = useMemo(() => [{
const AUTO_TERMINATE_OPTIONS = useMemo(() => {
const options = [{
label: lang('Weeks', 1, 'i'),
value: '7',
}, {
@ -83,7 +92,15 @@ const SettingsActiveSessions: FC<OwnProps & StateProps> = ({
}, {
label: lang('Months', 6, 'i'),
value: '183',
}], [lang]);
}];
if (ttlDays && ttlDays >= 365) {
options.push({
label: lang('Years', 1, 'i'),
value: '365',
});
}
return options;
}, [lang, ttlDays]);
const handleTerminateSessionClick = useCallback((hash: string) => {
terminateAuthorization({ hash });