hide verified devices by default with expand button
This commit is contained in:
parent
4a1dc55673
commit
6afeeddb36
2 changed files with 47 additions and 25 deletions
|
@ -114,6 +114,8 @@ const DevicesSection = ({devices, userId, loading}) => {
|
||||||
const MemberDeviceInfo = sdk.getComponent('rooms.MemberDeviceInfo');
|
const MemberDeviceInfo = sdk.getComponent('rooms.MemberDeviceInfo');
|
||||||
const Spinner = sdk.getComponent("elements.Spinner");
|
const Spinner = sdk.getComponent("elements.Spinner");
|
||||||
|
|
||||||
|
const [isExpanded, setExpanded] = useState(false);
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
// still loading
|
// still loading
|
||||||
return <Spinner />;
|
return <Spinner />;
|
||||||
|
@ -121,16 +123,37 @@ const DevicesSection = ({devices, userId, loading}) => {
|
||||||
if (devices === null) {
|
if (devices === null) {
|
||||||
return _t("Unable to load device list");
|
return _t("Unable to load device list");
|
||||||
}
|
}
|
||||||
if (devices.length === 0) {
|
|
||||||
return _t("No devices with registered encryption keys");
|
const unverifiedDevices = devices.filter(d => !d.isVerified());
|
||||||
|
const verifiedDevices = devices.filter(d => d.isVerified());
|
||||||
|
|
||||||
|
let expandButton;
|
||||||
|
if (verifiedDevices.length) {
|
||||||
|
if (isExpanded) {
|
||||||
|
expandButton = (<AccessibleButton onClick={() => setExpanded(false)}>
|
||||||
|
{_t("Hide verified Sign-In's")}
|
||||||
|
</AccessibleButton>);
|
||||||
|
} else {
|
||||||
|
expandButton = (<AccessibleButton onClick={() => setExpanded(true)}>
|
||||||
|
{_t("%(count)s verified Sign-In's", {count: verifiedDevices.length})}
|
||||||
|
</AccessibleButton>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let deviceList = unverifiedDevices.map((device, i) => {
|
||||||
|
return (<MemberDeviceInfo key={i} userId={userId} device={device} />);
|
||||||
|
});
|
||||||
|
if (isExpanded) {
|
||||||
|
const keyStart = unverifiedDevices.length;
|
||||||
|
deviceList = deviceList.concat(verifiedDevices.map((device, i) => {
|
||||||
|
return (<MemberDeviceInfo key={i + keyStart} userId={userId} device={device} />);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_UserInfo_container">
|
<div className="mx_UserInfo_devices">
|
||||||
<h3>{ _t("Trust & Devices") }</h3>
|
<div>{deviceList}</div>
|
||||||
<div className="mx_UserInfo_devices">
|
<div>{expandButton}</div>
|
||||||
{ devices.map((device, i) => <MemberDeviceInfo key={i} userId={userId} device={device} />) }
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1099,12 +1122,8 @@ const UserInfo = withLegacyMatrixClient(({matrixClient: cli, user, groupId, room
|
||||||
};
|
};
|
||||||
}, [cli, user.userId, isRoomEncrypted]);
|
}, [cli, user.userId, isRoomEncrypted]);
|
||||||
|
|
||||||
let devicesSection;
|
let text;
|
||||||
if (isRoomEncrypted) {
|
if (!isRoomEncrypted) {
|
||||||
devicesSection = <DevicesSection loading={devices === undefined} devices={devices} userId={user.userId} />;
|
|
||||||
} else {
|
|
||||||
let text;
|
|
||||||
|
|
||||||
if (!_enableDevices) {
|
if (!_enableDevices) {
|
||||||
text = _t("This client does not support end-to-end encryption.");
|
text = _t("This client does not support end-to-end encryption.");
|
||||||
} else if (room) {
|
} else if (room) {
|
||||||
|
@ -1112,19 +1131,18 @@ const UserInfo = withLegacyMatrixClient(({matrixClient: cli, user, groupId, room
|
||||||
} else {
|
} else {
|
||||||
// TODO what to render for GroupMember
|
// TODO what to render for GroupMember
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (text) {
|
text = _t("Messages in this room are end-to-end encrypted.");
|
||||||
devicesSection = (
|
|
||||||
<div className="mx_UserInfo_container">
|
|
||||||
<h3>{ _t("Trust & Devices") }</h3>
|
|
||||||
<div className="mx_UserInfo_devices">
|
|
||||||
{ text }
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const devicesSection = (
|
||||||
|
<div className="mx_UserInfo_container">
|
||||||
|
<h3>{ _t("Security") }</h3>
|
||||||
|
<p>{ text }</p>
|
||||||
|
<DevicesSection loading={devices === undefined} devices={devices} userId={user.userId} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
let e2eIcon;
|
let e2eIcon;
|
||||||
if (isRoomEncrypted && devices) {
|
if (isRoomEncrypted && devices) {
|
||||||
e2eIcon = <E2EIcon size={18} status={_getE2EStatus(devices)} isUser={true} />;
|
e2eIcon = <E2EIcon size={18} status={_getE2EStatus(devices)} isUser={true} />;
|
||||||
|
|
|
@ -1066,8 +1066,10 @@
|
||||||
"When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.": "When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.",
|
"When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.": "When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.",
|
||||||
"Members": "Members",
|
"Members": "Members",
|
||||||
"Files": "Files",
|
"Files": "Files",
|
||||||
"Trust & Devices": "Trust & Devices",
|
|
||||||
"Direct messages": "Direct messages",
|
"Direct messages": "Direct messages",
|
||||||
|
"Hide verified Sign-In's": "Hide verified Sign-In's",
|
||||||
|
"%(count)s verified Sign-In's|one": "1 verified Sign-In",
|
||||||
|
"%(count)s verified Sign-In's|other": "%(count)s verified Sign-In's",
|
||||||
"Direct message": "Direct message",
|
"Direct message": "Direct message",
|
||||||
"Unverify user": "Unverify user",
|
"Unverify user": "Unverify user",
|
||||||
"Options": "Options",
|
"Options": "Options",
|
||||||
|
@ -1079,6 +1081,8 @@
|
||||||
"Failed to deactivate user": "Failed to deactivate user",
|
"Failed to deactivate user": "Failed to deactivate user",
|
||||||
"This client does not support end-to-end encryption.": "This client does not support end-to-end encryption.",
|
"This client does not support end-to-end encryption.": "This client does not support end-to-end encryption.",
|
||||||
"Messages in this room are not end-to-end encrypted.": "Messages in this room are not end-to-end encrypted.",
|
"Messages in this room are not end-to-end encrypted.": "Messages in this room are not end-to-end encrypted.",
|
||||||
|
"Messages in this room are end-to-end encrypted.": "Messages in this room are end-to-end encrypted.",
|
||||||
|
"Security": "Security",
|
||||||
"Sunday": "Sunday",
|
"Sunday": "Sunday",
|
||||||
"Monday": "Monday",
|
"Monday": "Monday",
|
||||||
"Tuesday": "Tuesday",
|
"Tuesday": "Tuesday",
|
||||||
|
|
Loading…
Reference in a new issue