From dd8cac307cdc19625cb94f0393ed2ccdd77761a1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Oct 2020 17:38:59 +0100 Subject: [PATCH] Convert shouldHideEvent to TS Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/{shouldHideEvent.js => shouldHideEvent.ts} | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) rename src/{shouldHideEvent.js => shouldHideEvent.ts} (86%) diff --git a/src/shouldHideEvent.js b/src/shouldHideEvent.ts similarity index 86% rename from src/shouldHideEvent.js rename to src/shouldHideEvent.ts index b1533ae835..2a47b9c417 100644 --- a/src/shouldHideEvent.js +++ b/src/shouldHideEvent.ts @@ -14,10 +14,20 @@ limitations under the License. */ +import {MatrixEvent} from "matrix-js-sdk/src/models/event"; + import SettingsStore from "./settings/SettingsStore"; -function memberEventDiff(ev) { - const diff = { +interface IDiff { + isMemberEvent: boolean; + isJoin?: boolean; + isPart?: boolean; + isDisplaynameChange?: boolean; + isAvatarChange?: boolean; +} + +function memberEventDiff(ev: MatrixEvent): IDiff { + const diff: IDiff = { isMemberEvent: ev.getType() === 'm.room.member', }; @@ -37,7 +47,7 @@ function memberEventDiff(ev) { return diff; } -export default function shouldHideEvent(ev) { +export default function shouldHideEvent(ev: MatrixEvent): boolean { // Wrap getValue() for readability. Calling the SettingsStore can be // fairly resource heavy, so the checks below should avoid hitting it // where possible.