Fix selecting tombstone room opens replacement room (#1820)
This commit is contained in:
@@ -14,6 +14,8 @@ import {
|
|||||||
} from 'matrix-js-sdk';
|
} from 'matrix-js-sdk';
|
||||||
import { IImageInfo, IThumbnailContent, IVideoInfo } from '../../types/matrix/common';
|
import { IImageInfo, IThumbnailContent, IVideoInfo } from '../../types/matrix/common';
|
||||||
import { AccountDataEvent } from '../../types/matrix/accountData';
|
import { AccountDataEvent } from '../../types/matrix/accountData';
|
||||||
|
import { getStateEvent } from './room';
|
||||||
|
import { StateEvent } from '../../types/matrix/room';
|
||||||
|
|
||||||
export const matchMxId = (id: string): RegExpMatchArray | null =>
|
export const matchMxId = (id: string): RegExpMatchArray | null =>
|
||||||
id.match(/^([@!$+#])(\S+):(\S+)$/);
|
id.match(/^([@!$+#])(\S+):(\S+)$/);
|
||||||
@@ -42,8 +44,12 @@ export const parseMatrixToUrl = (url: string): [string | undefined, string | und
|
|||||||
export const getCanonicalAliasRoomId = (mx: MatrixClient, alias: string): string | undefined =>
|
export const getCanonicalAliasRoomId = (mx: MatrixClient, alias: string): string | undefined =>
|
||||||
mx.getRooms()?.find((room) => room.getCanonicalAlias() === alias)?.roomId;
|
mx.getRooms()?.find((room) => room.getCanonicalAlias() === alias)?.roomId;
|
||||||
|
|
||||||
export const getCanonicalAliasOrRoomId = (mx: MatrixClient, roomId: string): string =>
|
export const getCanonicalAliasOrRoomId = (mx: MatrixClient, roomId: string): string => {
|
||||||
mx.getRoom(roomId)?.getCanonicalAlias() || roomId;
|
const room = mx.getRoom(roomId);
|
||||||
|
if (!room) return roomId;
|
||||||
|
if (getStateEvent(room, StateEvent.RoomTombstone) !== undefined) return roomId;
|
||||||
|
return room.getCanonicalAlias() || roomId;
|
||||||
|
};
|
||||||
|
|
||||||
export const getImageInfo = (img: HTMLImageElement, fileOrBlob: File | Blob): IImageInfo => {
|
export const getImageInfo = (img: HTMLImageElement, fileOrBlob: File | Blob): IImageInfo => {
|
||||||
const info: IImageInfo = {};
|
const info: IImageInfo = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user