Merge branch 'develop' into florianduros/tooltip-update
This commit is contained in:
commit
e53b175a6b
18 changed files with 823 additions and 8 deletions
|
@ -290,6 +290,20 @@ function DevicesSection({
|
|||
let expandHideCaption;
|
||||
let expandIconClasses = "mx_E2EIcon";
|
||||
|
||||
const dehydratedDeviceIds: string[] = [];
|
||||
for (const device of devices) {
|
||||
if (device.dehydrated) {
|
||||
dehydratedDeviceIds.push(device.deviceId);
|
||||
}
|
||||
}
|
||||
// If the user has exactly one device marked as dehydrated, we consider
|
||||
// that as the dehydrated device, and hide it as a normal device (but
|
||||
// indicate that the user is using a dehydrated device). If the user has
|
||||
// more than one, that is anomalous, and we show all the devices so that
|
||||
// nothing is hidden.
|
||||
const dehydratedDeviceId: string | undefined = dehydratedDeviceIds.length == 1 ? dehydratedDeviceIds[0] : undefined;
|
||||
let dehydratedDeviceInExpandSection = false;
|
||||
|
||||
if (isUserVerified) {
|
||||
for (let i = 0; i < devices.length; ++i) {
|
||||
const device = devices[i];
|
||||
|
@ -302,7 +316,13 @@ function DevicesSection({
|
|||
const isVerified = deviceTrust && (isMe ? deviceTrust.crossSigningVerified : deviceTrust.isVerified());
|
||||
|
||||
if (isVerified) {
|
||||
expandSectionDevices.push(device);
|
||||
// don't show dehydrated device as a normal device, if it's
|
||||
// verified
|
||||
if (device.deviceId === dehydratedDeviceId) {
|
||||
dehydratedDeviceInExpandSection = true;
|
||||
} else {
|
||||
expandSectionDevices.push(device);
|
||||
}
|
||||
} else {
|
||||
unverifiedDevices.push(device);
|
||||
}
|
||||
|
@ -311,6 +331,10 @@ function DevicesSection({
|
|||
expandHideCaption = _t("user_info|hide_verified_sessions");
|
||||
expandIconClasses += " mx_E2EIcon_verified";
|
||||
} else {
|
||||
if (dehydratedDeviceId) {
|
||||
devices = devices.filter((device) => device.deviceId !== dehydratedDeviceId);
|
||||
dehydratedDeviceInExpandSection = true;
|
||||
}
|
||||
expandSectionDevices = devices;
|
||||
expandCountCaption = _t("user_info|count_of_sessions", { count: devices.length });
|
||||
expandHideCaption = _t("user_info|hide_sessions");
|
||||
|
@ -347,6 +371,9 @@ function DevicesSection({
|
|||
);
|
||||
}),
|
||||
);
|
||||
if (dehydratedDeviceInExpandSection) {
|
||||
deviceList.push(<div>{_t("user_info|dehydrated_device_enabled")}</div>);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -77,6 +77,7 @@ export enum OwnDevicesError {
|
|||
}
|
||||
export type DevicesState = {
|
||||
devices: DevicesDictionary;
|
||||
dehydratedDeviceId?: string;
|
||||
pushers: IPusher[];
|
||||
localNotificationSettings: Map<string, LocalNotificationSettings>;
|
||||
currentDeviceId: string;
|
||||
|
@ -97,6 +98,7 @@ export const useOwnDevices = (): DevicesState => {
|
|||
const userId = matrixClient.getSafeUserId();
|
||||
|
||||
const [devices, setDevices] = useState<DevicesState["devices"]>({});
|
||||
const [dehydratedDeviceId, setDehydratedDeviceId] = useState<DevicesState["dehydratedDeviceId"]>(undefined);
|
||||
const [pushers, setPushers] = useState<DevicesState["pushers"]>([]);
|
||||
const [localNotificationSettings, setLocalNotificationSettings] = useState<
|
||||
DevicesState["localNotificationSettings"]
|
||||
|
@ -131,6 +133,21 @@ export const useOwnDevices = (): DevicesState => {
|
|||
});
|
||||
setLocalNotificationSettings(notificationSettings);
|
||||
|
||||
const ownUserId = matrixClient.getUserId()!;
|
||||
const userDevices = (await matrixClient.getCrypto()?.getUserDeviceInfo([ownUserId]))?.get(ownUserId);
|
||||
const dehydratedDeviceIds: string[] = [];
|
||||
for (const device of userDevices?.values() ?? []) {
|
||||
if (device.dehydrated) {
|
||||
dehydratedDeviceIds.push(device.deviceId);
|
||||
}
|
||||
}
|
||||
// If the user has exactly one device marked as dehydrated, we consider
|
||||
// that as the dehydrated device, and hide it as a normal device (but
|
||||
// indicate that the user is using a dehydrated device). If the user has
|
||||
// more than one, that is anomalous, and we show all the devices so that
|
||||
// nothing is hidden.
|
||||
setDehydratedDeviceId(dehydratedDeviceIds.length == 1 ? dehydratedDeviceIds[0] : undefined);
|
||||
|
||||
setIsLoadingDeviceList(false);
|
||||
} catch (error) {
|
||||
if ((error as MatrixError).httpStatus == 404) {
|
||||
|
@ -228,6 +245,7 @@ export const useOwnDevices = (): DevicesState => {
|
|||
|
||||
return {
|
||||
devices,
|
||||
dehydratedDeviceId,
|
||||
pushers,
|
||||
localNotificationSettings,
|
||||
currentDeviceId,
|
||||
|
|
|
@ -42,6 +42,7 @@ import type { IServerVersions } from "matrix-js-sdk/src/matrix";
|
|||
import SettingsTab from "../SettingsTab";
|
||||
import { SettingsSection } from "../../shared/SettingsSection";
|
||||
import SettingsSubsection, { SettingsSubsectionText } from "../../shared/SettingsSubsection";
|
||||
import { useOwnDevices } from "../../devices/useOwnDevices";
|
||||
|
||||
interface IIgnoredUserProps {
|
||||
userId: string;
|
||||
|
@ -49,6 +50,23 @@ interface IIgnoredUserProps {
|
|||
inProgress: boolean;
|
||||
}
|
||||
|
||||
const DehydratedDeviceStatus: React.FC = () => {
|
||||
const { dehydratedDeviceId } = useOwnDevices();
|
||||
|
||||
if (dehydratedDeviceId) {
|
||||
return (
|
||||
<div className="mx_SettingsSubsection_content">
|
||||
<div className="mx_SettingsFlag_label">{_t("settings|security|dehydrated_device_enabled")}</div>
|
||||
<div className="mx_SettingsSubsection_text">
|
||||
{_t("settings|security|dehydrated_device_description")}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export class IgnoredUser extends React.Component<IIgnoredUserProps> {
|
||||
private onUnignoreClicked = (): void => {
|
||||
this.props.onUnignored(this.props.userId);
|
||||
|
@ -279,6 +297,7 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
const secureBackup = (
|
||||
<SettingsSubsection heading={_t("common|secure_backup")}>
|
||||
<SecureBackupPanel />
|
||||
<DehydratedDeviceStatus />
|
||||
</SettingsSubsection>
|
||||
);
|
||||
|
||||
|
|
|
@ -150,6 +150,7 @@ const useSignOut = (
|
|||
const SessionManagerTab: React.FC = () => {
|
||||
const {
|
||||
devices,
|
||||
dehydratedDeviceId,
|
||||
pushers,
|
||||
localNotificationSettings,
|
||||
currentDeviceId,
|
||||
|
@ -208,6 +209,9 @@ const SessionManagerTab: React.FC = () => {
|
|||
};
|
||||
|
||||
const { [currentDeviceId]: currentDevice, ...otherDevices } = devices;
|
||||
if (dehydratedDeviceId && otherDevices[dehydratedDeviceId]?.isVerified) {
|
||||
delete otherDevices[dehydratedDeviceId];
|
||||
}
|
||||
const otherSessionsCount = Object.keys(otherDevices).length;
|
||||
const shouldShowOtherSessions = otherSessionsCount > 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue