Fix crash in manage device
This commit is contained in:
parent
2ded7d9b1f
commit
4a35aa7272
2 changed files with 12 additions and 10 deletions
|
@ -16,11 +16,11 @@ import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog';
|
||||||
|
|
||||||
import './ProfileEditor.scss';
|
import './ProfileEditor.scss';
|
||||||
|
|
||||||
// TODO Fix bug that prevents 'Save' button from enabling up until second changed.
|
|
||||||
function ProfileEditor({ userId }) {
|
function ProfileEditor({ userId }) {
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = initMatrix.matrixClient;
|
||||||
const user = mx.getUser(mx.getUserId());
|
const user = mx.getUser(mx.getUserId());
|
||||||
|
const fallbackUsername = userId.match(/^@?(\S+):(\S+)$/)[1];
|
||||||
|
|
||||||
const displayNameRef = useRef(null);
|
const displayNameRef = useRef(null);
|
||||||
const [avatarSrc, setAvatarSrc] = useState(user.avatarUrl ? mx.mxcUrlToHttp(user.avatarUrl, 80, 80, 'crop') : null);
|
const [avatarSrc, setAvatarSrc] = useState(user.avatarUrl ? mx.mxcUrlToHttp(user.avatarUrl, 80, 80, 'crop') : null);
|
||||||
|
@ -96,7 +96,7 @@ function ProfileEditor({ userId }) {
|
||||||
const renderInfo = () => (
|
const renderInfo = () => (
|
||||||
<div className="profile-editor__info" style={{ marginBottom: avatarSrc ? '24px' : '0' }}>
|
<div className="profile-editor__info" style={{ marginBottom: avatarSrc ? '24px' : '0' }}>
|
||||||
<div>
|
<div>
|
||||||
<Text variant="h2" primary weight="medium">{twemojify(username)}</Text>
|
<Text variant="h2" primary weight="medium">{twemojify(username) ?? fallbackUsername}</Text>
|
||||||
<IconButton
|
<IconButton
|
||||||
src={PencilIC}
|
src={PencilIC}
|
||||||
size="extra-small"
|
size="extra-small"
|
||||||
|
@ -111,7 +111,7 @@ function ProfileEditor({ userId }) {
|
||||||
return (
|
return (
|
||||||
<div className="profile-editor">
|
<div className="profile-editor">
|
||||||
<ImageUpload
|
<ImageUpload
|
||||||
text={username}
|
text={username ?? fallbackUsername}
|
||||||
bgColor={colorMXID(userId)}
|
bgColor={colorMXID(userId)}
|
||||||
imageSrc={avatarSrc}
|
imageSrc={avatarSrc}
|
||||||
onUpload={handleAvatarUpload}
|
onUpload={handleAvatarUpload}
|
||||||
|
|
|
@ -180,6 +180,7 @@ function DeviceManage() {
|
||||||
}
|
}
|
||||||
content={(
|
content={(
|
||||||
<>
|
<>
|
||||||
|
{lastTS && (
|
||||||
<Text variant="b3">
|
<Text variant="b3">
|
||||||
Last activity
|
Last activity
|
||||||
<span style={{ color: 'var(--tc-surface-normal)' }}>
|
<span style={{ color: 'var(--tc-surface-normal)' }}>
|
||||||
|
@ -187,6 +188,7 @@ function DeviceManage() {
|
||||||
</span>
|
</span>
|
||||||
{lastIP ? ` at ${lastIP}` : ''}
|
{lastIP ? ` at ${lastIP}` : ''}
|
||||||
</Text>
|
</Text>
|
||||||
|
)}
|
||||||
{isCurrentDevice && (
|
{isCurrentDevice && (
|
||||||
<Text style={{ marginTop: 'var(--sp-ultra-tight)' }} variant="b3">
|
<Text style={{ marginTop: 'var(--sp-ultra-tight)' }} variant="b3">
|
||||||
{`Session Key: ${initMatrix.matrixClient.getDeviceEd25519Key().match(/.{1,4}/g).join(' ')}`}
|
{`Session Key: ${initMatrix.matrixClient.getDeviceEd25519Key().match(/.{1,4}/g).join(' ')}`}
|
||||||
|
|
Loading…
Reference in a new issue