From 9ceeb2d220acb0acdccd98cb57bbb960f338c19e Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Thu, 14 Oct 2021 17:09:00 +0100 Subject: [PATCH] Delete UnstableValue and use hardcoded value for m.thread --- src/@types/event.ts | 14 +++----------- src/models/event.ts | 3 +-- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/@types/event.ts b/src/@types/event.ts index 581b80d4425..b7ecb83390f 100644 --- a/src/@types/event.ts +++ b/src/@types/event.ts @@ -94,7 +94,9 @@ export enum RelationType { Replace = "m.replace", /** * Note, "io.element.thread" is hardcoded - * TypeScript does not allow computed values in enums + * Should be replaced with "m.thread" once MSC3440 lands + * Can not use `UnstableValue` as TypeScript does not + * allow computed values in enums * https://github.com/microsoft/TypeScript/issues/27976 */ Thread = "io.element.thread", @@ -174,16 +176,6 @@ export const UNSTABLE_ELEMENT_FUNCTIONAL_USERS = new UnstableValue( "io.element.functional_members", "io.element.functional_members"); -/** - * Note, "io.element.thread" is hardcoded in the RelationType enum - * TypeScript does not allow computed values in enums - * https://github.com/microsoft/TypeScript/issues/27976 - */ -export const UNSTABLE_ELEMENT_THREAD_RELATION = new UnstableValue( - "m.thread", - "io.element.thread", -); - export interface IEncryptedFile { url: string; mimetype?: string; diff --git a/src/models/event.ts b/src/models/event.ts index 70bc02d4b5c..b6e41982f5b 100644 --- a/src/models/event.ts +++ b/src/models/event.ts @@ -28,7 +28,6 @@ import { EventType, MsgType, RelationType, - UNSTABLE_ELEMENT_THREAD_RELATION, } from "../@types/event"; import { Crypto } from "../crypto"; import { deepSortedObjectEntries } from "../utils"; @@ -423,7 +422,7 @@ export class MatrixEvent extends EventEmitter { */ public get threadRootId(): string { const relatesTo = this.getWireContent()?.["m.relates_to"]; - if (relatesTo?.rel_type === UNSTABLE_ELEMENT_THREAD_RELATION.name) { + if (relatesTo?.rel_type === RelationType.Thread) { return relatesTo.event_id; } }