Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add config setting to disable bulk unverified sessions nag #9657

Merged
merged 11 commits into from
Dec 2, 2022
14 changes: 13 additions & 1 deletion src/DeviceListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
removeClientInformation,
} from "./utils/device/clientInformation";
import SettingsStore, { CallbackFn } from "./settings/SettingsStore";
import { UIFeature } from "./settings/UIFeature";

const KEY_BACKUP_POLL_INTERVAL = 5 * 60 * 1000;

Expand All @@ -68,6 +69,7 @@ export default class DeviceListener {
private displayingToastsForDeviceIds = new Set<string>();
private running = false;
private shouldRecordClientInformation = false;
private enableBulkUnverifiedSessionsReminder = true;
private deviceClientInformationSettingWatcherRef: string | undefined;

public static sharedInstance() {
Expand All @@ -86,6 +88,8 @@ export default class DeviceListener {
MatrixClientPeg.get().on(ClientEvent.Sync, this.onSync);
MatrixClientPeg.get().on(RoomStateEvent.Events, this.onRoomStateEvents);
this.shouldRecordClientInformation = SettingsStore.getValue('deviceClientInformationOptIn');
// only configurable in config, so we don't need to watch the value
this.enableBulkUnverifiedSessionsReminder = SettingsStore.getValue(UIFeature.BulkUnverifiedSessionsReminder);
this.deviceClientInformationSettingWatcherRef = SettingsStore.watchSetting(
'deviceClientInformationOptIn',
null,
Expand Down Expand Up @@ -306,6 +310,9 @@ export default class DeviceListener {
// Unverified devices that have appeared since then
const newUnverifiedDeviceIds = new Set<string>();

const isCurrentDeviceTrusted = crossSigningReady &&
await (cli.checkDeviceTrust(cli.getUserId(), cli.deviceId)).isCrossSigningVerified();

// as long as cross-signing isn't ready,
// you can't see or dismiss any device toasts
if (crossSigningReady) {
Expand All @@ -329,7 +336,12 @@ export default class DeviceListener {
logger.debug("Currently showing toasts for: " + Array.from(this.displayingToastsForDeviceIds).join(','));

// Display or hide the batch toast for old unverified sessions
if (oldUnverifiedDeviceIds.size > 0) {
// don't show the toast if the current device is unverified
if (
oldUnverifiedDeviceIds.size > 0
&& isCurrentDeviceTrusted
&& this.enableBulkUnverifiedSessionsReminder
) {
showBulkUnverifiedSessionsToast(oldUnverifiedDeviceIds);
} else {
hideBulkUnverifiedSessionsToast();
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@
"Yes": "Yes",
"No": "No",
"Help improve %(analyticsOwner)s": "Help improve %(analyticsOwner)s",
"You have unverified logins": "You have unverified logins",
"You have unverified sessions": "You have unverified sessions",
"Review to ensure your account is safe": "Review to ensure your account is safe",
"Review": "Review",
"Later": "Later",
Expand Down
4 changes: 4 additions & 0 deletions src/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,10 @@ export const SETTINGS: {[setting: string]: ISetting} = {
supportedLevels: LEVELS_UI_FEATURE,
default: true,
},
[UIFeature.BulkUnverifiedSessionsReminder]: {
supportedLevels: LEVELS_UI_FEATURE,
default: true,
},

// Electron-specific settings, they are stored by Electron and set/read over an IPC.
// We store them over there are they are necessary to know before the renderer process launches.
Expand Down
1 change: 1 addition & 0 deletions src/settings/UIFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export enum UIFeature {
AdvancedSettings = "UIFeature.advancedSettings",
RoomHistorySettings = "UIFeature.roomHistorySettings",
TimelineEnableRelativeDates = "UIFeature.timelineEnableRelativeDates",
BulkUnverifiedSessionsReminder = "UIFeature.BulkUnverifiedSessionsReminder",
}

export enum UIComponent {
Expand Down
2 changes: 1 addition & 1 deletion src/toasts/BulkUnverifiedSessionsToast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const showToast = (deviceIds: Set<string>) => {

ToastStore.sharedInstance().addOrReplaceToast({
key: TOAST_KEY,
title: _t("You have unverified logins"),
title: _t("You have unverified sessions"),
icon: "verification_warning",
props: {
description: _t("Review to ensure your account is safe"),
Expand Down
Loading