From d7730f417b4b166fc288ad8debc219cdacf35f68 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Fri, 28 Mar 2025 08:46:43 +0000 Subject: [PATCH] Hide an event notification if it is redacted (#29605) * Hide notifications from events that have been redacted. * lint * add a void * Remove ?. --- src/BasePlatform.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts index 2093881cc5..c7b7825fe6 100644 --- a/src/BasePlatform.ts +++ b/src/BasePlatform.ts @@ -16,6 +16,7 @@ import { type SSOAction, encodeUnpaddedBase64, type OidcRegistrationClientMetadata, + MatrixEventEvent, } from "matrix-js-sdk/src/matrix"; import { logger } from "matrix-js-sdk/src/logger"; @@ -228,6 +229,16 @@ export default abstract class BasePlatform { window.focus(); }; + const closeHandler = (): void => notification.close(); + + // Clear a notification from a redacted event. + if (ev) { + ev.once(MatrixEventEvent.BeforeRedaction, closeHandler); + notification.onclose = () => { + ev.off(MatrixEventEvent.BeforeRedaction, closeHandler); + }; + } + return notification; }