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