From 50b9da75976296a6b498f40c5abea9bfc55ffac6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 13 Aug 2020 16:40:18 +0100 Subject: [PATCH] Put message previews for Emoji behind Labs --- src/settings/Settings.ts | 12 ++++++++++++ src/stores/room-list/previews/IPreview.ts | 2 +- .../room-list/previews/ReactionEventPreview.ts | 7 +++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index 714d80f983..3d18c14e16 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -158,6 +158,18 @@ export const SETTINGS: {[setting: string]: ISetting} = { supportedLevels: LEVELS_FEATURE, default: false, }, + "feature_roomlist_preview_reactions_dms": { + isFeature: true, + displayName: _td("Show message previews for reactions in DMs"), + supportedLevels: LEVELS_FEATURE, + default: false, + }, + "feature_roomlist_preview_reactions_all": { + isFeature: true, + displayName: _td("Show message previews for reactions in all rooms"), + supportedLevels: LEVELS_FEATURE, + default: false, + }, "advancedRoomListLogging": { // TODO: Remove flag before launch: https://github.com/vector-im/element-web/issues/14231 displayName: _td("Enable advanced debugging for the room list"), diff --git a/src/stores/room-list/previews/IPreview.ts b/src/stores/room-list/previews/IPreview.ts index 9beb92bfbf..fe69637543 100644 --- a/src/stores/room-list/previews/IPreview.ts +++ b/src/stores/room-list/previews/IPreview.ts @@ -27,5 +27,5 @@ export interface IPreview { * @param tagId Optional. The tag where the room the event was sent in resides. * @returns The preview. */ - getTextFor(event: MatrixEvent, tagId?: TagID): string; + getTextFor(event: MatrixEvent, tagId?: TagID): string | null; } diff --git a/src/stores/room-list/previews/ReactionEventPreview.ts b/src/stores/room-list/previews/ReactionEventPreview.ts index 07fac107ca..c8f2be9a6e 100644 --- a/src/stores/room-list/previews/ReactionEventPreview.ts +++ b/src/stores/room-list/previews/ReactionEventPreview.ts @@ -19,9 +19,16 @@ import { TagID } from "../models"; import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { getSenderName, isSelf, shouldPrefixMessagesIn } from "./utils"; import { _t } from "../../../languageHandler"; +import SettingsStore from "../../../settings/SettingsStore"; +import DMRoomMap from "../../../utils/DMRoomMap"; export class ReactionEventPreview implements IPreview { public getTextFor(event: MatrixEvent, tagId?: TagID): string { + const showDms = SettingsStore.isFeatureEnabled("feature_roomlist_preview_reactions_dms"); + const showAll = SettingsStore.isFeatureEnabled("feature_roomlist_preview_reactions_all"); + + if (!showAll && (!showDms || DMRoomMap.shared().getUserIdForRoomId(event.getRoomId()))) return null; + const relation = event.getRelation(); if (!relation) return null; // invalid reaction (probably redacted)