Skip to content

Commit

Permalink
Prevent state events being rendered with invalid state keys
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Apr 13, 2021
1 parent e79ad34 commit c25df51
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/components/views/rooms/EventTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,24 @@ const stateEventTileTypes = {
'm.room.related_groups': 'messages.TextualEvent', // legacy communities flair
};

const stateEventSingular = new Set([
EventType.RoomEncryption,
EventType.RoomCanonicalAlias,
EventType.RoomCreate,
EventType.RoomName,
EventType.RoomAvatar,
EventType.RoomHistoryVisibility,
EventType.RoomTopic,
EventType.RoomPowerLevels,
EventType.RoomPinnedEvents,
EventType.RoomServerAcl,
WIDGET_LAYOUT_EVENT_TYPE,
EventType.RoomTombstone,
EventType.RoomJoinRules,
EventType.RoomGuestAccess,
'm.room.related_groups',
]);

// Add all the Mjolnir stuff to the renderer
for (const evType of ALL_RULE_TYPES) {
stateEventTileTypes[evType] = 'messages.TextualEvent';
Expand Down Expand Up @@ -130,7 +148,12 @@ export function getHandlerTile(ev) {
}
}

return ev.isState() ? stateEventTileTypes[type] : eventTileTypes[type];
if (ev.isState()) {
if (stateEventSingular.has(type) && ev.getStateKey() !== "") return undefined;
return stateEventTileTypes[type];
}

return eventTileTypes[type];
}

const MAX_READ_AVATARS = 5;
Expand Down

0 comments on commit c25df51

Please sign in to comment.