From 493d3ae28859907010815dfbe4804247b6e79e15 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 14 Sep 2020 14:35:08 +0100 Subject: [PATCH 1/4] Don't show Notifications Prompt Toast if user has master rule enabled --- src/Notifier.ts | 3 ++- src/settings/controllers/NotificationControllers.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Notifier.ts b/src/Notifier.ts index 473de6c161..03f037be98 100644 --- a/src/Notifier.ts +++ b/src/Notifier.ts @@ -33,6 +33,7 @@ import Modal from './Modal'; import SettingsStore from "./settings/SettingsStore"; import { hideToast as hideNotificationsToast } from "./toasts/DesktopNotificationsToast"; import {SettingLevel} from "./settings/SettingLevel"; +import {isPushNotifyDisabled} from "./settings/controllers/NotificationControllers"; /* * Dispatches: @@ -302,7 +303,7 @@ export const Notifier = { return false; } const isGuest = client.isGuest(); - return !isGuest && this.supportsDesktopNotifications() && + return !isGuest && this.supportsDesktopNotifications() && !isPushNotifyDisabled() && !this.isEnabled() && !this._isToolbarHidden(); }, diff --git a/src/settings/controllers/NotificationControllers.ts b/src/settings/controllers/NotificationControllers.ts index bf5971d02e..323c64e9c3 100644 --- a/src/settings/controllers/NotificationControllers.ts +++ b/src/settings/controllers/NotificationControllers.ts @@ -24,7 +24,7 @@ import {PushProcessor} from "matrix-js-sdk/src/pushprocessor"; // .m.rule.master being enabled means all events match that push rule // default action on this rule is dont_notify, but it could be something else -function isPushNotifyDisabled(): boolean { +export function isPushNotifyDisabled(): boolean { // Return the value of the master push rule as a default const processor = new PushProcessor(MatrixClientPeg.get()); const masterRule = processor.getPushRuleById(".m.rule.master"); From b177843e459a01c8a4792f7fe7134f34c633ea84 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 14 Sep 2020 22:03:54 -0600 Subject: [PATCH 2/4] Remove defunct "always show encryption icons" setting It doesn't do anything in practice. Fixes https://github.com/vector-im/element-web/issues/8725 --- res/css/views/rooms/_EventTile.scss | 10 ---------- src/components/views/rooms/EventTile.js | 6 +----- .../settings/tabs/user/PreferencesUserSettingsTab.js | 1 - src/settings/Settings.ts | 5 ----- 4 files changed, 1 insertion(+), 21 deletions(-) diff --git a/res/css/views/rooms/_EventTile.scss b/res/css/views/rooms/_EventTile.scss index eb0e1dd7b0..3b9a491db5 100644 --- a/res/css/views/rooms/_EventTile.scss +++ b/res/css/views/rooms/_EventTile.scss @@ -394,16 +394,6 @@ $left-gutter: 64px; opacity: 1; } -.mx_EventTile_e2eIcon_hidden { - display: none; -} - -/* always override hidden attribute for blocked and warning */ -.mx_EventTile_e2eIcon_hidden[src*="img/e2e-blocked.svg"], -.mx_EventTile_e2eIcon_hidden[src*="img/e2e-warning.svg"] { - display: block; -} - .mx_EventTile_keyRequestInfo { font-size: $font-12px; } diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 647ef585d7..ab9f240f2d 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -1027,11 +1027,7 @@ class E2ePadlock extends React.Component { tooltip = ; } - let classes = `mx_EventTile_e2eIcon mx_EventTile_e2eIcon_${this.props.icon}`; - if (!SettingsStore.getValue("alwaysShowEncryptionIcons")) { - classes += ' mx_EventTile_e2eIcon_hidden'; - } - + const classes = `mx_EventTile_e2eIcon mx_EventTile_e2eIcon_${this.props.icon}`; return (
Date: Mon, 14 Sep 2020 22:31:45 -0600 Subject: [PATCH 3/4] Update i18n --- src/i18n/strings/en_EN.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 93781160ce..fc8bef0fa8 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -474,7 +474,6 @@ "Show timestamps in 12 hour format (e.g. 2:30pm)": "Show timestamps in 12 hour format (e.g. 2:30pm)", "Always show message timestamps": "Always show message timestamps", "Autoplay GIFs and videos": "Autoplay GIFs and videos", - "Always show encryption icons": "Always show encryption icons", "Show a reminder to enable Secure Message Recovery in encrypted rooms": "Show a reminder to enable Secure Message Recovery in encrypted rooms", "Enable automatic language detection for syntax highlighting": "Enable automatic language detection for syntax highlighting", "Show avatars in user and room mentions": "Show avatars in user and room mentions", From 6b5426bddd7f882a818bbab5db46f70491ae8e5a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 15 Sep 2020 13:58:29 +0100 Subject: [PATCH 4/4] Rename toolbar Notifier methods to prompt --- src/Notifier.ts | 10 +++++----- src/components/structures/MatrixChat.tsx | 2 +- src/toasts/DesktopNotificationsToast.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Notifier.ts b/src/Notifier.ts index 03f037be98..2643de1abc 100644 --- a/src/Notifier.ts +++ b/src/Notifier.ts @@ -259,7 +259,7 @@ export const Notifier = { } // set the notifications_hidden flag, as the user has knowingly interacted // with the setting we shouldn't nag them any further - this.setToolbarHidden(true); + this.setPromptHidden(true); }, isEnabled: function() { @@ -284,7 +284,7 @@ export const Notifier = { return SettingsStore.getValue("audioNotificationsEnabled"); }, - setToolbarHidden: function(hidden: boolean, persistent = true) { + setPromptHidden: function(hidden: boolean, persistent = true) { this.toolbarHidden = hidden; Analytics.trackEvent('Notifier', 'Set Toolbar Hidden', hidden); @@ -297,17 +297,17 @@ export const Notifier = { } }, - shouldShowToolbar: function() { + shouldShowPrompt: function() { const client = MatrixClientPeg.get(); if (!client) { return false; } const isGuest = client.isGuest(); return !isGuest && this.supportsDesktopNotifications() && !isPushNotifyDisabled() && - !this.isEnabled() && !this._isToolbarHidden(); + !this.isEnabled() && !this._isPromptHidden(); }, - _isToolbarHidden: function() { + _isPromptHidden: function() { // Check localStorage for any such meta data if (global.localStorage) { return global.localStorage.getItem("notifications_hidden") === "true"; diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index d3d5835dae..4cdb58014e 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -1344,7 +1344,7 @@ export default class MatrixChat extends React.PureComponent { this.firstSyncComplete = true; this.firstSyncPromise.resolve(); - if (Notifier.shouldShowToolbar()) { + if (Notifier.shouldShowPrompt()) { showNotificationsToast(); } diff --git a/src/toasts/DesktopNotificationsToast.ts b/src/toasts/DesktopNotificationsToast.ts index 413e82e20b..d8aa7647a3 100644 --- a/src/toasts/DesktopNotificationsToast.ts +++ b/src/toasts/DesktopNotificationsToast.ts @@ -24,7 +24,7 @@ const onAccept = () => { }; const onReject = () => { - Notifier.setToolbarHidden(true); + Notifier.setPromptHidden(true); }; const TOAST_KEY = "desktopnotifications";