hide verified devices by default with expand button

This commit is contained in:
Bruno Windels 2019-11-13 15:59:49 +01:00
parent 4a1dc55673
commit 6afeeddb36
2 changed files with 47 additions and 25 deletions

View file

@ -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">
<h3>{ _t("Trust & Devices") }</h3>
<div className="mx_UserInfo_devices"> <div className="mx_UserInfo_devices">
{ devices.map((device, i) => <MemberDeviceInfo key={i} userId={userId} device={device} />) } <div>{deviceList}</div>
</div> <div>{expandButton}</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;
if (isRoomEncrypted) {
devicesSection = <DevicesSection loading={devices === undefined} devices={devices} userId={user.userId} />;
} else {
let text; let text;
if (!isRoomEncrypted) {
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,18 +1131,17 @@ const UserInfo = withLegacyMatrixClient(({matrixClient: cli, user, groupId, room
} else { } else {
// TODO what to render for GroupMember // TODO what to render for GroupMember
} }
} else {
text = _t("Messages in this room are end-to-end encrypted.");
}
if (text) { const devicesSection = (
devicesSection = (
<div className="mx_UserInfo_container"> <div className="mx_UserInfo_container">
<h3>{ _t("Trust & Devices") }</h3> <h3>{ _t("Security") }</h3>
<div className="mx_UserInfo_devices"> <p>{ text }</p>
{ text } <DevicesSection loading={devices === undefined} devices={devices} userId={user.userId} />
</div>
</div> </div>
); );
}
}
let e2eIcon; let e2eIcon;
if (isRoomEncrypted && devices) { if (isRoomEncrypted && devices) {

View file

@ -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",