From 7b061dc17eee2fbb2188ca11160de16e96ac0f3a Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 10 Dec 2021 12:57:54 +0000 Subject: [PATCH 1/2] Don't show polls in timeline if polls are disabled --- src/components/structures/MessagePanel.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/structures/MessagePanel.tsx b/src/components/structures/MessagePanel.tsx index 7db09c6720b..46656302c3c 100644 --- a/src/components/structures/MessagePanel.tsx +++ b/src/components/structures/MessagePanel.tsx @@ -50,6 +50,7 @@ import TileErrorBoundary from '../views/messages/TileErrorBoundary'; import { RoomPermalinkCreator } from "../../utils/permalinks/Permalinks"; import EditorStateTransfer from "../../utils/EditorStateTransfer"; import { Action } from '../../dispatcher/actions'; +import { POLL_START_EVENT_TYPE } from '../../polls/consts'; const CONTINUATION_MAX_INTERVAL = 5 * 60 * 1000; // 5 minutes const continuedTypes = [EventType.Sticker, EventType.RoomMessage]; @@ -461,6 +462,13 @@ export default class MessagePanel extends React.Component { return false; // no tile = no show } + if ( + POLL_START_EVENT_TYPE.matches(mxEv.getType()) && + !SettingsStore.getValue("feature_polls") + ) { + return false; + } + // Always show highlighted event if (this.props.highlightedEventId === mxEv.getId()) return true; From a9be10c0393b95c6b96da13b5d76ea164d35a8c3 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 10 Dec 2021 13:08:28 +0000 Subject: [PATCH 2/2] Move poll feature check into getHandlerTile, near similar ones --- src/components/structures/MessagePanel.tsx | 8 -------- src/components/views/rooms/EventTile.tsx | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/structures/MessagePanel.tsx b/src/components/structures/MessagePanel.tsx index 46656302c3c..7db09c6720b 100644 --- a/src/components/structures/MessagePanel.tsx +++ b/src/components/structures/MessagePanel.tsx @@ -50,7 +50,6 @@ import TileErrorBoundary from '../views/messages/TileErrorBoundary'; import { RoomPermalinkCreator } from "../../utils/permalinks/Permalinks"; import EditorStateTransfer from "../../utils/EditorStateTransfer"; import { Action } from '../../dispatcher/actions'; -import { POLL_START_EVENT_TYPE } from '../../polls/consts'; const CONTINUATION_MAX_INTERVAL = 5 * 60 * 1000; // 5 minutes const continuedTypes = [EventType.Sticker, EventType.RoomMessage]; @@ -462,13 +461,6 @@ export default class MessagePanel extends React.Component { return false; // no tile = no show } - if ( - POLL_START_EVENT_TYPE.matches(mxEv.getType()) && - !SettingsStore.getValue("feature_polls") - ) { - return false; - } - // Always show highlighted event if (this.props.highlightedEventId === mxEv.getId()) return true; diff --git a/src/components/views/rooms/EventTile.tsx b/src/components/views/rooms/EventTile.tsx index 8128e5975bb..077ef3d1c8a 100644 --- a/src/components/views/rooms/EventTile.tsx +++ b/src/components/views/rooms/EventTile.tsx @@ -172,6 +172,13 @@ export function getHandlerTile(ev) { } } + if ( + POLL_START_EVENT_TYPE.matches(type) && + !SettingsStore.getValue("feature_polls") + ) { + return undefined; + } + if (ev.isState()) { if (stateEventSingular.has(type) && ev.getStateKey() !== "") return undefined; return stateEventTileTypes[type];