diff --git a/src/RoomNotifs.ts b/src/RoomNotifs.ts index d23703e581..1f39eddc17 100644 --- a/src/RoomNotifs.ts +++ b/src/RoomNotifs.ts @@ -18,6 +18,7 @@ limitations under the License. import { PushProcessor } from 'matrix-js-sdk/src/pushprocessor'; import { NotificationCountType, Room } from "matrix-js-sdk/src/models/room"; import { ConditionKind, IPushRule, PushRuleActionName, PushRuleKind } from "matrix-js-sdk/src/@types/PushRules"; +import { EventType } from 'matrix-js-sdk/src/@types/event'; import { MatrixClientPeg } from './MatrixClientPeg'; @@ -120,7 +121,7 @@ export function getUnreadNotificationCount(room: Room, type: NotificationCountTy // Check notification counts in the old room just in case there's some lost // there. We only go one level down to avoid performance issues, and theory // is that 1st generation rooms will have already been read by the 3rd generation. - const createEvent = room.currentState.getStateEvents("m.room.create", ""); + const createEvent = room.currentState.getStateEvents(EventType.RoomCreate, ""); if (createEvent && createEvent.getContent()['predecessor']) { const oldRoomId = createEvent.getContent()['predecessor']['room_id']; const oldRoom = MatrixClientPeg.get().getRoom(oldRoomId); diff --git a/src/VoipUserMapper.ts b/src/VoipUserMapper.ts index 6a9170e468..c98c39a88d 100644 --- a/src/VoipUserMapper.ts +++ b/src/VoipUserMapper.ts @@ -16,6 +16,7 @@ limitations under the License. import { Room } from 'matrix-js-sdk/src/models/room'; import { logger } from "matrix-js-sdk/src/logger"; +import { EventType } from 'matrix-js-sdk/src/@types/event'; import { ensureVirtualRoomExists, findDMForUser } from './createRoom'; import { MatrixClientPeg } from "./MatrixClientPeg"; @@ -87,7 +88,7 @@ export default class VoipUserMapper { // way we can recognise a virtual room we've created when it first arrives down // our stream. We don't trust this in general though, as it could be faked by an // inviter: our main source of truth is the DM state. - const roomCreateEvent = room.currentState.getStateEvents("m.room.create", ""); + const roomCreateEvent = room.currentState.getStateEvents(EventType.RoomCreate, ""); if (!roomCreateEvent || !roomCreateEvent.getContent()) return false; // we only look at this for rooms we created (so inviters can't just cause rooms // to be invisible) diff --git a/src/components/structures/MessagePanel.tsx b/src/components/structures/MessagePanel.tsx index 034297edae..689d02155f 100644 --- a/src/components/structures/MessagePanel.tsx +++ b/src/components/structures/MessagePanel.tsx @@ -682,6 +682,7 @@ export default class MessagePanel extends React.Component { for (const Grouper of groupers) { if (Grouper.canStartGroup(this, mxEv) && !this.props.disableGrouping) { grouper = new Grouper(this, mxEv, prevEvent, lastShownEvent, nextEvent, nextTile); + break; // break on first grouper } } if (!grouper) { @@ -1156,7 +1157,7 @@ class CreationGrouper extends BaseGrouper { // Get sender profile from the latest event in the summary as the m.room.create doesn't contain one const ev = this.events[this.events.length - 1]; - let summaryText; + let summaryText: string; const roomId = ev.getRoomId(); const creator = ev.sender ? ev.sender.name : ev.getSender(); if (DMRoomMap.shared().getUserIdForRoomId(roomId)) { @@ -1334,5 +1335,5 @@ class MainGrouper extends BaseGrouper { } } -// all the grouper classes that we use +// all the grouper classes that we use, ordered by priority const groupers = [CreationGrouper, MainGrouper]; diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 82bed241b4..1bcd348ba7 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -1768,7 +1768,7 @@ export class RoomView extends React.Component { }; private getOldRoom() { - const createEvent = this.state.room.currentState.getStateEvents("m.room.create", ""); + const createEvent = this.state.room.currentState.getStateEvents(EventType.RoomCreate, ""); if (!createEvent || !createEvent.getContent()['predecessor']) return null; return this.context.getRoom(createEvent.getContent()['predecessor']['room_id']); diff --git a/src/components/views/rooms/MessageComposer.tsx b/src/components/views/rooms/MessageComposer.tsx index 695a160b39..a36c9a9f08 100644 --- a/src/components/views/rooms/MessageComposer.tsx +++ b/src/components/views/rooms/MessageComposer.tsx @@ -19,7 +19,7 @@ import classNames from 'classnames'; import { MatrixEvent, IEventRelation } from "matrix-js-sdk/src/models/event"; import { Room } from "matrix-js-sdk/src/models/room"; import { RoomMember } from "matrix-js-sdk/src/models/room-member"; -import { RelationType } from 'matrix-js-sdk/src/@types/event'; +import { EventType, RelationType } from 'matrix-js-sdk/src/@types/event'; import { _t } from '../../../languageHandler'; import { MatrixClientPeg } from '../../../MatrixClientPeg'; @@ -223,7 +223,7 @@ export default class MessageComposer extends React.Component { const replacementRoom = MatrixClientPeg.get().getRoom(replacementRoomId); let createEventId = null; if (replacementRoom) { - const createEvent = replacementRoom.currentState.getStateEvents('m.room.create', ''); + const createEvent = replacementRoom.currentState.getStateEvents(EventType.RoomCreate, ''); if (createEvent && createEvent.getId()) createEventId = createEvent.getId(); } diff --git a/src/stores/room-list/RoomListStore.ts b/src/stores/room-list/RoomListStore.ts index 8488e31506..2142efa098 100644 --- a/src/stores/room-list/RoomListStore.ts +++ b/src/stores/room-list/RoomListStore.ts @@ -317,7 +317,7 @@ export class RoomListStoreClass extends AsyncStoreWithClient { if (oldMembership !== EffectiveMembership.Join && newMembership === EffectiveMembership.Join) { // If we're joining an upgraded room, we'll want to make sure we don't proliferate // the dead room in the list. - const createEvent = membershipPayload.room.currentState.getStateEvents("m.room.create", ""); + const createEvent = membershipPayload.room.currentState.getStateEvents(EventType.RoomCreate, ""); if (createEvent && createEvent.getContent()['predecessor']) { const prevRoom = this.matrixClient.getRoom(createEvent.getContent()['predecessor']['room_id']); if (prevRoom) {