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,23 +55,32 @@ 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(() => {
const options = [{
label: lang('Weeks', 1, 'i'), label: lang('Weeks', 1, 'i'),
value: '7', value: '7',
}, { }, {
@ -83,7 +92,15 @@ const SettingsActiveSessions: FC<OwnProps & StateProps> = ({
}, { }, {
label: lang('Months', 6, 'i'), label: lang('Months', 6, 'i'),
value: '183', 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) => { const handleTerminateSessionClick = useCallback((hash: string) => {
terminateAuthorization({ hash }); terminateAuthorization({ hash });