From 4a35aa72722d7b2d0182dc65cbea89ab13fa316c Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Wed, 7 Sep 2022 13:14:15 +0530 Subject: [PATCH] Fix crash in manage device --- .../organisms/profile-editor/ProfileEditor.jsx | 6 +++--- src/app/organisms/settings/DeviceManage.jsx | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/app/organisms/profile-editor/ProfileEditor.jsx b/src/app/organisms/profile-editor/ProfileEditor.jsx index 972192ef..5085bfb9 100644 --- a/src/app/organisms/profile-editor/ProfileEditor.jsx +++ b/src/app/organisms/profile-editor/ProfileEditor.jsx @@ -16,11 +16,11 @@ import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog'; import './ProfileEditor.scss'; -// TODO Fix bug that prevents 'Save' button from enabling up until second changed. function ProfileEditor({ userId }) { const [isEditing, setIsEditing] = useState(false); const mx = initMatrix.matrixClient; const user = mx.getUser(mx.getUserId()); + const fallbackUsername = userId.match(/^@?(\S+):(\S+)$/)[1]; const displayNameRef = useRef(null); const [avatarSrc, setAvatarSrc] = useState(user.avatarUrl ? mx.mxcUrlToHttp(user.avatarUrl, 80, 80, 'crop') : null); @@ -96,7 +96,7 @@ function ProfileEditor({ userId }) { const renderInfo = () => (
- {twemojify(username)} + {twemojify(username) ?? fallbackUsername} - - Last activity - - {dateFormat(new Date(lastTS), ' hh:MM TT, dd/mm/yyyy')} - - {lastIP ? ` at ${lastIP}` : ''} - + {lastTS && ( + + Last activity + + {dateFormat(new Date(lastTS), ' hh:MM TT, dd/mm/yyyy')} + + {lastIP ? ` at ${lastIP}` : ''} + + )} {isCurrentDevice && ( {`Session Key: ${initMatrix.matrixClient.getDeviceEd25519Key().match(/.{1,4}/g).join(' ')}`}