Fix room create tile not showing up with hidden events shown (#7810)

* Replace m.room.create with enum

* Fix room create tile not showing up with hidden events shown
pull/21833/head
Michael Telatynski 2022-02-15 21:05:41 +00:00 committed by GitHub
parent b5e3ba28d9
commit c2cf3a2d9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 8 deletions

View File

@ -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);

View File

@ -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)

View File

@ -682,6 +682,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
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];

View File

@ -1768,7 +1768,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
};
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']);

View File

@ -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<IProps, IState> {
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();
}

View File

@ -317,7 +317,7 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
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) {