Skip to content

Commit 74f6e11

Browse files
committed
fallback to created time for last login
1 parent e37ef3c commit 74f6e11

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/libs/UserUtils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ function getLoginKey(login: NewLogin) {
4949
return `${login.partnerID}_${login.partnerUserID}`;
5050
}
5151

52+
function getLastLogin(login: NewLogin) {
53+
return new Date(login.lastLogin) > new Date(login.created) ? login.lastLogin : login.created;
54+
}
55+
5256
const DEVICE_PARTNER_IDS = new Set<number>([CONST.PARTNER_ID.IPHONE, CONST.PARTNER_ID.ANDROID, CONST.PARTNER_ID.NEWDOT]);
5357

5458
function isLoginRevokable(login: NewLogin) {
@@ -194,6 +198,7 @@ export {
194198
isCurrentUserValidated,
195199
getContactMethodsOptions,
196200
getLoginKey,
201+
getLastLogin,
197202
getRevokableLogins,
198203
hasDeviceManagementError,
199204
};

src/pages/settings/Security/DeviceManagementPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import useOnyx from '@hooks/useOnyx';
1313
import useThemeStyles from '@hooks/useThemeStyles';
1414
import {clearRevokeError, revokeDevice} from '@libs/actions/User';
1515
import Navigation from '@libs/Navigation/Navigation';
16-
import {getLoginKey, getRevokableLogins} from '@libs/UserUtils';
16+
import {getLastLogin, getLoginKey, getRevokableLogins} from '@libs/UserUtils';
1717
import ONYXKEYS from '@src/ONYXKEYS';
1818
import type {Login} from '@src/types/onyx/Logins';
1919

@@ -33,7 +33,7 @@ function DeviceManagementPage() {
3333
contentContainerStyle={[styles.flexRow, styles.alignItemsCenter, styles.pv3, styles.gap3]}
3434
>
3535
<View style={[styles.flex1, styles.flexColumn, styles.gap1]}>
36-
<Text style={[styles.textLabelSupporting]}>{datetimeToRelative(item.lastLogin)}</Text>
36+
<Text style={[styles.textLabelSupporting]}>{datetimeToRelative(getLastLogin(item))}</Text>
3737
<Text>{item.additionalData ? `${deviceName} ${deviceVersion ? `${deviceVersion} ` : ''}(${os} ${osVersion})` : translate('deviceManagementPage.unknownDevice')}</Text>
3838
</View>
3939
<Button

0 commit comments

Comments
 (0)