Skip to content

Commit

Permalink
Delete UnstableValue and use hardcoded value for m.thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Germain Souquet committed Oct 14, 2021
1 parent 7b89862 commit 9ceeb2d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
14 changes: 3 additions & 11 deletions src/@types/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/models/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
EventType,
MsgType,
RelationType,
UNSTABLE_ELEMENT_THREAD_RELATION,
} from "../@types/event";
import { Crypto } from "../crypto";
import { deepSortedObjectEntries } from "../utils";
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 9ceeb2d

Please sign in to comment.