You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-30 04:23:07 +03:00
Stop labelling threads as experimental (#3064)
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -590,7 +590,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
|
|
||||||
it("should handle thread replies with server support by fetching a contiguous thread timeline", async () => {
|
it("should handle thread replies with server support by fetching a contiguous thread timeline", async () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
||||||
await client.stopClient(); // we don't need the client to be syncing at this time
|
await client.stopClient(); // we don't need the client to be syncing at this time
|
||||||
const room = client.getRoom(roomId)!;
|
const room = client.getRoom(roomId)!;
|
||||||
@ -647,7 +647,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
|
|
||||||
it("should return relevant timeline from non-thread timelineSet when asking for the thread root", async () => {
|
it("should return relevant timeline from non-thread timelineSet when asking for the thread root", async () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
||||||
client.stopClient(); // we don't need the client to be syncing at this time
|
client.stopClient(); // we don't need the client to be syncing at this time
|
||||||
const room = client.getRoom(roomId)!;
|
const room = client.getRoom(roomId)!;
|
||||||
@ -680,7 +680,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
|
|
||||||
it("should return undefined when event is not in the thread that the given timelineSet is representing", () => {
|
it("should return undefined when event is not in the thread that the given timelineSet is representing", () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
||||||
client.stopClient(); // we don't need the client to be syncing at this time
|
client.stopClient(); // we don't need the client to be syncing at this time
|
||||||
const room = client.getRoom(roomId)!;
|
const room = client.getRoom(roomId)!;
|
||||||
@ -709,7 +709,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
|
|
||||||
it("should return undefined when event is within a thread but timelineSet is not", () => {
|
it("should return undefined when event is within a thread but timelineSet is not", () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
||||||
client.stopClient(); // we don't need the client to be syncing at this time
|
client.stopClient(); // we don't need the client to be syncing at this time
|
||||||
const room = client.getRoom(roomId)!;
|
const room = client.getRoom(roomId)!;
|
||||||
@ -1127,7 +1127,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Stable);
|
Thread.setServerSideSupport(FeatureSupport.Stable);
|
||||||
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
||||||
Thread.setServerSideFwdPaginationSupport(FeatureSupport.Stable);
|
Thread.setServerSideFwdPaginationSupport(FeatureSupport.Stable);
|
||||||
@ -1263,7 +1263,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
describe("with server compatibility", function () {
|
describe("with server compatibility", function () {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Stable);
|
Thread.setServerSideSupport(FeatureSupport.Stable);
|
||||||
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
||||||
Thread.setServerSideFwdPaginationSupport(FeatureSupport.Stable);
|
Thread.setServerSideFwdPaginationSupport(FeatureSupport.Stable);
|
||||||
@ -1421,7 +1421,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Stable);
|
Thread.setServerSideSupport(FeatureSupport.Stable);
|
||||||
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
||||||
Thread.setServerSideFwdPaginationSupport(FeatureSupport.Stable);
|
Thread.setServerSideFwdPaginationSupport(FeatureSupport.Stable);
|
||||||
@ -1473,7 +1473,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
describe("without server compatibility", function () {
|
describe("without server compatibility", function () {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
||||||
Thread.setServerSideListSupport(FeatureSupport.None);
|
Thread.setServerSideListSupport(FeatureSupport.None);
|
||||||
});
|
});
|
||||||
@ -1539,7 +1539,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
|
|
||||||
it("should add lazy loading filter", async () => {
|
it("should add lazy loading filter", async () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
||||||
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -1567,7 +1567,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
|
|
||||||
it("should correctly pass pagination token", async () => {
|
it("should correctly pass pagination token", async () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
||||||
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
||||||
|
|
||||||
@ -1892,7 +1892,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
|
|
||||||
it("in stable mode", async () => {
|
it("in stable mode", async () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Stable);
|
Thread.setServerSideSupport(FeatureSupport.Stable);
|
||||||
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
||||||
Thread.setServerSideFwdPaginationSupport(FeatureSupport.Stable);
|
Thread.setServerSideFwdPaginationSupport(FeatureSupport.Stable);
|
||||||
@ -1902,7 +1902,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
|
|
||||||
it("in backwards compatible unstable mode", async () => {
|
it("in backwards compatible unstable mode", async () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
||||||
Thread.setServerSideListSupport(FeatureSupport.Experimental);
|
Thread.setServerSideListSupport(FeatureSupport.Experimental);
|
||||||
Thread.setServerSideFwdPaginationSupport(FeatureSupport.Experimental);
|
Thread.setServerSideFwdPaginationSupport(FeatureSupport.Experimental);
|
||||||
@ -1912,7 +1912,7 @@ describe("MatrixClient event timelines", function () {
|
|||||||
|
|
||||||
it("in backwards compatible mode", async () => {
|
it("in backwards compatible mode", async () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
client.clientOpts.experimentalThreadSupport = true;
|
client.clientOpts.threadSupport = true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
Thread.setServerSideSupport(FeatureSupport.Experimental);
|
||||||
Thread.setServerSideListSupport(FeatureSupport.None);
|
Thread.setServerSideListSupport(FeatureSupport.None);
|
||||||
Thread.setServerSideFwdPaginationSupport(FeatureSupport.None);
|
Thread.setServerSideFwdPaginationSupport(FeatureSupport.None);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -35,7 +35,7 @@ describe("MatrixClient", function () {
|
|||||||
let store: MemoryStore | undefined;
|
let store: MemoryStore | undefined;
|
||||||
|
|
||||||
const defaultClientOpts: IStoredClientOpts = {
|
const defaultClientOpts: IStoredClientOpts = {
|
||||||
experimentalThreadSupport: false,
|
threadSupport: false,
|
||||||
};
|
};
|
||||||
const setupTests = (): [MatrixClient, HttpBackend, MemoryStore] => {
|
const setupTests = (): [MatrixClient, HttpBackend, MemoryStore] => {
|
||||||
const store = new MemoryStore();
|
const store = new MemoryStore();
|
||||||
@ -671,7 +671,7 @@ describe("MatrixClient", function () {
|
|||||||
// @ts-ignore setting private property
|
// @ts-ignore setting private property
|
||||||
client!.clientOpts = {
|
client!.clientOpts = {
|
||||||
...defaultClientOpts,
|
...defaultClientOpts,
|
||||||
experimentalThreadSupport: true,
|
threadSupport: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const eventPollResponseReference = buildEventPollResponseReference();
|
const eventPollResponseReference = buildEventPollResponseReference();
|
||||||
@ -702,7 +702,7 @@ describe("MatrixClient", function () {
|
|||||||
// @ts-ignore setting private property
|
// @ts-ignore setting private property
|
||||||
client!.clientOpts = {
|
client!.clientOpts = {
|
||||||
...defaultClientOpts,
|
...defaultClientOpts,
|
||||||
experimentalThreadSupport: true,
|
threadSupport: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const eventPollStartThreadRoot = buildEventPollStartThreadRoot();
|
const eventPollStartThreadRoot = buildEventPollStartThreadRoot();
|
||||||
@ -726,7 +726,7 @@ describe("MatrixClient", function () {
|
|||||||
// @ts-ignore setting private property
|
// @ts-ignore setting private property
|
||||||
client!.clientOpts = {
|
client!.clientOpts = {
|
||||||
...defaultClientOpts,
|
...defaultClientOpts,
|
||||||
experimentalThreadSupport: true,
|
threadSupport: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const eventPollResponseReference = buildEventPollResponseReference();
|
const eventPollResponseReference = buildEventPollResponseReference();
|
||||||
@ -750,7 +750,7 @@ describe("MatrixClient", function () {
|
|||||||
// @ts-ignore setting private property
|
// @ts-ignore setting private property
|
||||||
client!.clientOpts = {
|
client!.clientOpts = {
|
||||||
...defaultClientOpts,
|
...defaultClientOpts,
|
||||||
experimentalThreadSupport: true,
|
threadSupport: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const eventPollStartThreadRoot = buildEventPollStartThreadRoot();
|
const eventPollStartThreadRoot = buildEventPollStartThreadRoot();
|
||||||
@ -774,7 +774,7 @@ describe("MatrixClient", function () {
|
|||||||
// @ts-ignore setting private property
|
// @ts-ignore setting private property
|
||||||
client!.clientOpts = {
|
client!.clientOpts = {
|
||||||
...defaultClientOpts,
|
...defaultClientOpts,
|
||||||
experimentalThreadSupport: true,
|
threadSupport: true,
|
||||||
};
|
};
|
||||||
// This is based on recording the events in a real room:
|
// This is based on recording the events in a real room:
|
||||||
|
|
||||||
@ -831,7 +831,7 @@ describe("MatrixClient", function () {
|
|||||||
// @ts-ignore setting private property
|
// @ts-ignore setting private property
|
||||||
client!.clientOpts = {
|
client!.clientOpts = {
|
||||||
...defaultClientOpts,
|
...defaultClientOpts,
|
||||||
experimentalThreadSupport: true,
|
threadSupport: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const threadRootEvent = buildEventPollStartThreadRoot();
|
const threadRootEvent = buildEventPollStartThreadRoot();
|
||||||
@ -857,7 +857,7 @@ describe("MatrixClient", function () {
|
|||||||
// @ts-ignore setting private property
|
// @ts-ignore setting private property
|
||||||
client!.clientOpts = {
|
client!.clientOpts = {
|
||||||
...defaultClientOpts,
|
...defaultClientOpts,
|
||||||
experimentalThreadSupport: true,
|
threadSupport: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const threadRootEvent = buildEventPollStartThreadRoot();
|
const threadRootEvent = buildEventPollStartThreadRoot();
|
||||||
@ -878,7 +878,7 @@ describe("MatrixClient", function () {
|
|||||||
// @ts-ignore setting private property
|
// @ts-ignore setting private property
|
||||||
client!.clientOpts = {
|
client!.clientOpts = {
|
||||||
...defaultClientOpts,
|
...defaultClientOpts,
|
||||||
experimentalThreadSupport: true,
|
threadSupport: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const threadRootEvent = buildEventPollStartThreadRoot();
|
const threadRootEvent = buildEventPollStartThreadRoot();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -476,7 +476,7 @@ export class MockCallMatrixClient extends TypedEventEmitter<EmittedEvents, Emitt
|
|||||||
public getRooms = jest.fn<Room[], []>().mockReturnValue([]);
|
public getRooms = jest.fn<Room[], []>().mockReturnValue([]);
|
||||||
public getRoom = jest.fn();
|
public getRoom = jest.fn();
|
||||||
|
|
||||||
public supportsExperimentalThreads(): boolean {
|
public supportsThreads(): boolean {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public async decryptEventIfNeeded(): Promise<void> {}
|
public async decryptEventIfNeeded(): Promise<void> {}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -147,7 +147,7 @@ describe("EventTimelineSet", () => {
|
|||||||
let thread: Thread;
|
let thread: Thread;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
(client.supportsExperimentalThreads as jest.Mock).mockReturnValue(true);
|
(client.supportsThreads as jest.Mock).mockReturnValue(true);
|
||||||
thread = new Thread("!thread_id:server", messageEvent, { room, client });
|
thread = new Thread("!thread_id:server", messageEvent, { room, client });
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ describe("EventTimelineSet", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should allow edits to be added to thread timeline", async () => {
|
it("should allow edits to be added to thread timeline", async () => {
|
||||||
jest.spyOn(client, "supportsExperimentalThreads").mockReturnValue(true);
|
jest.spyOn(client, "supportsThreads").mockReturnValue(true);
|
||||||
jest.spyOn(client, "getEventMapper").mockReturnValue(eventMapperFor(client, {}));
|
jest.spyOn(client, "getEventMapper").mockReturnValue(eventMapperFor(client, {}));
|
||||||
Thread.hasServerSideSupport = FeatureSupport.Stable;
|
Thread.hasServerSideSupport = FeatureSupport.Stable;
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ describe("EventTimelineSet", () => {
|
|||||||
let thread: Thread;
|
let thread: Thread;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
(client.supportsExperimentalThreads as jest.Mock).mockReturnValue(true);
|
(client.supportsThreads as jest.Mock).mockReturnValue(true);
|
||||||
thread = new Thread("!thread_id:server", messageEvent, { room, client });
|
thread = new Thread("!thread_id:server", messageEvent, { room, client });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
import { mocked } from "jest-mock";
|
import { mocked } from "jest-mock";
|
||||||
|
|
||||||
import { logger } from "../../src/logger";
|
import { logger } from "../../src/logger";
|
||||||
import { ClientEvent, ITurnServerResponse, MatrixClient, Store } from "../../src/client";
|
import { ClientEvent, IMatrixClientCreateOpts, ITurnServerResponse, MatrixClient, Store } from "../../src/client";
|
||||||
import { Filter } from "../../src/filter";
|
import { Filter } from "../../src/filter";
|
||||||
import { DEFAULT_TREE_POWER_LEVELS_TEMPLATE } from "../../src/models/MSC3089TreeSpace";
|
import { DEFAULT_TREE_POWER_LEVELS_TEMPLATE } from "../../src/models/MSC3089TreeSpace";
|
||||||
import {
|
import {
|
||||||
@ -276,7 +276,7 @@ describe("MatrixClient", function () {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeClient() {
|
function makeClient(opts?: Partial<IMatrixClientCreateOpts>) {
|
||||||
client = new MatrixClient({
|
client = new MatrixClient({
|
||||||
baseUrl: "https://my.home.server",
|
baseUrl: "https://my.home.server",
|
||||||
idBaseUrl: identityServerUrl,
|
idBaseUrl: identityServerUrl,
|
||||||
@ -285,6 +285,7 @@ describe("MatrixClient", function () {
|
|||||||
store: store,
|
store: store,
|
||||||
scheduler: scheduler,
|
scheduler: scheduler,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
|
...(opts || {}),
|
||||||
});
|
});
|
||||||
// FIXME: We shouldn't be yanking http like this.
|
// FIXME: We shouldn't be yanking http like this.
|
||||||
client.http = (["authedRequest", "getContentUri", "request", "uploadContent"] as const).reduce((r, k) => {
|
client.http = (["authedRequest", "getContentUri", "request", "uploadContent"] as const).reduce((r, k) => {
|
||||||
@ -1456,9 +1457,20 @@ describe("MatrixClient", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("threads", () => {
|
describe("threads", () => {
|
||||||
|
it.each([
|
||||||
|
{ startOpts: {}, hasThreadSupport: false },
|
||||||
|
{ startOpts: { threadSupport: true }, hasThreadSupport: true },
|
||||||
|
{ startOpts: { threadSupport: false }, hasThreadSupport: false },
|
||||||
|
{ startOpts: { experimentalThreadSupport: true }, hasThreadSupport: true },
|
||||||
|
{ startOpts: { experimentalThreadSupport: true, threadSupport: false }, hasThreadSupport: false },
|
||||||
|
])("enabled thread support for the SDK instance ", async ({ startOpts, hasThreadSupport }) => {
|
||||||
|
await client.startClient(startOpts);
|
||||||
|
expect(client.supportsThreads()).toBe(hasThreadSupport);
|
||||||
|
});
|
||||||
|
|
||||||
it("partitions root events to room timeline and thread timeline", () => {
|
it("partitions root events to room timeline and thread timeline", () => {
|
||||||
const supportsExperimentalThreads = client.supportsExperimentalThreads;
|
const supportsThreads = client.supportsThreads;
|
||||||
client.supportsExperimentalThreads = () => true;
|
client.supportsThreads = () => true;
|
||||||
const room = new Room("!room1:matrix.org", client, userId);
|
const room = new Room("!room1:matrix.org", client, userId);
|
||||||
|
|
||||||
const rootEvent = new MatrixEvent({
|
const rootEvent = new MatrixEvent({
|
||||||
@ -1487,7 +1499,7 @@ describe("MatrixClient", function () {
|
|||||||
expect(threadEvents).toHaveLength(1);
|
expect(threadEvents).toHaveLength(1);
|
||||||
|
|
||||||
// Restore method
|
// Restore method
|
||||||
client.supportsExperimentalThreads = supportsExperimentalThreads;
|
client.supportsThreads = supportsThreads;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ describe("Thread", () => {
|
|||||||
...mockClientMethodsUser(),
|
...mockClientMethodsUser(),
|
||||||
getRoom: jest.fn().mockImplementation(() => room),
|
getRoom: jest.fn().mockImplementation(() => room),
|
||||||
decryptEventIfNeeded: jest.fn().mockResolvedValue(void 0),
|
decryptEventIfNeeded: jest.fn().mockResolvedValue(void 0),
|
||||||
supportsExperimentalThreads: jest.fn().mockReturnValue(true),
|
supportsThreads: jest.fn().mockReturnValue(true),
|
||||||
});
|
});
|
||||||
client.reEmitter = mock(ReEmitter, "ReEmitter");
|
client.reEmitter = mock(ReEmitter, "ReEmitter");
|
||||||
client.canSupport = new Map();
|
client.canSupport = new Map();
|
||||||
@ -195,7 +195,7 @@ describe("Thread", () => {
|
|||||||
...mockClientMethodsUser(),
|
...mockClientMethodsUser(),
|
||||||
getRoom: jest.fn().mockImplementation(() => room),
|
getRoom: jest.fn().mockImplementation(() => room),
|
||||||
decryptEventIfNeeded: jest.fn().mockResolvedValue(void 0),
|
decryptEventIfNeeded: jest.fn().mockResolvedValue(void 0),
|
||||||
supportsExperimentalThreads: jest.fn().mockReturnValue(true),
|
supportsThreads: jest.fn().mockReturnValue(true),
|
||||||
});
|
});
|
||||||
client.reEmitter = mock(ReEmitter, "ReEmitter");
|
client.reEmitter = mock(ReEmitter, "ReEmitter");
|
||||||
client.canSupport = new Map();
|
client.canSupport = new Map();
|
||||||
|
@ -56,7 +56,7 @@ describe("fixNotificationCountOnDecryption", () => {
|
|||||||
getPushActionsForEvent: jest.fn().mockReturnValue(mkPushAction(true, true)),
|
getPushActionsForEvent: jest.fn().mockReturnValue(mkPushAction(true, true)),
|
||||||
getRoom: jest.fn().mockImplementation(() => room),
|
getRoom: jest.fn().mockImplementation(() => room),
|
||||||
decryptEventIfNeeded: jest.fn().mockResolvedValue(void 0),
|
decryptEventIfNeeded: jest.fn().mockResolvedValue(void 0),
|
||||||
supportsExperimentalThreads: jest.fn().mockReturnValue(true),
|
supportsThreads: jest.fn().mockReturnValue(true),
|
||||||
});
|
});
|
||||||
mockClient.reEmitter = mock(ReEmitter, "ReEmitter");
|
mockClient.reEmitter = mock(ReEmitter, "ReEmitter");
|
||||||
mockClient.canSupport = new Map();
|
mockClient.canSupport = new Map();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2022, 2023 The Matrix.org Foundation C.I.C.
|
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -1624,7 +1624,7 @@ describe("Room", function () {
|
|||||||
describe("addPendingEvent", function () {
|
describe("addPendingEvent", function () {
|
||||||
it("should add pending events to the pendingEventList if " + "pendingEventOrdering == 'detached'", function () {
|
it("should add pending events to the pendingEventList if " + "pendingEventOrdering == 'detached'", function () {
|
||||||
const client = new TestClient("@alice:example.com", "alicedevice").client;
|
const client = new TestClient("@alice:example.com", "alicedevice").client;
|
||||||
client.supportsExperimentalThreads = () => true;
|
client.supportsThreads = () => true;
|
||||||
const room = new Room(roomId, client, userA, {
|
const room = new Room(roomId, client, userA, {
|
||||||
pendingEventOrdering: PendingEventOrdering.Detached,
|
pendingEventOrdering: PendingEventOrdering.Detached,
|
||||||
});
|
});
|
||||||
@ -2470,7 +2470,7 @@ describe("Room", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Edits update the lastReply event", async () => {
|
it("Edits update the lastReply event", async () => {
|
||||||
room.client.supportsExperimentalThreads = () => true;
|
room.client.supportsThreads = () => true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Stable);
|
Thread.setServerSideSupport(FeatureSupport.Stable);
|
||||||
|
|
||||||
const randomMessage = mkMessage();
|
const randomMessage = mkMessage();
|
||||||
@ -2541,7 +2541,7 @@ describe("Room", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Redactions to thread responses decrement the length", async () => {
|
it("Redactions to thread responses decrement the length", async () => {
|
||||||
room.client.supportsExperimentalThreads = () => true;
|
room.client.supportsThreads = () => true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Stable);
|
Thread.setServerSideSupport(FeatureSupport.Stable);
|
||||||
|
|
||||||
const threadRoot = mkMessage();
|
const threadRoot = mkMessage();
|
||||||
@ -2608,7 +2608,7 @@ describe("Room", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Redactions to reactions in threads do not decrement the length", async () => {
|
it("Redactions to reactions in threads do not decrement the length", async () => {
|
||||||
room.client.supportsExperimentalThreads = () => true;
|
room.client.supportsThreads = () => true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Stable);
|
Thread.setServerSideSupport(FeatureSupport.Stable);
|
||||||
|
|
||||||
const threadRoot = mkMessage();
|
const threadRoot = mkMessage();
|
||||||
@ -2648,7 +2648,7 @@ describe("Room", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should not decrement the length when the thread root is redacted", async () => {
|
it("should not decrement the length when the thread root is redacted", async () => {
|
||||||
room.client.supportsExperimentalThreads = () => true;
|
room.client.supportsThreads = () => true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Stable);
|
Thread.setServerSideSupport(FeatureSupport.Stable);
|
||||||
|
|
||||||
const threadRoot = mkMessage();
|
const threadRoot = mkMessage();
|
||||||
@ -2689,7 +2689,7 @@ describe("Room", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Redacting the lastEvent finds a new lastEvent", async () => {
|
it("Redacting the lastEvent finds a new lastEvent", async () => {
|
||||||
room.client.supportsExperimentalThreads = () => true;
|
room.client.supportsThreads = () => true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Stable);
|
Thread.setServerSideSupport(FeatureSupport.Stable);
|
||||||
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
Thread.setServerSideListSupport(FeatureSupport.Stable);
|
||||||
|
|
||||||
@ -2796,7 +2796,7 @@ describe("Room", function () {
|
|||||||
|
|
||||||
describe("eventShouldLiveIn", () => {
|
describe("eventShouldLiveIn", () => {
|
||||||
const client = new TestClient(userA).client;
|
const client = new TestClient(userA).client;
|
||||||
client.supportsExperimentalThreads = () => true;
|
client.supportsThreads = () => true;
|
||||||
Thread.setServerSideSupport(FeatureSupport.Stable);
|
Thread.setServerSideSupport(FeatureSupport.Stable);
|
||||||
const room = new Room(roomId, client, userA);
|
const room = new Room(roomId, client, userA);
|
||||||
|
|
||||||
@ -3307,7 +3307,7 @@ describe("Room", function () {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
client = getMockClientWithEventEmitter({
|
client = getMockClientWithEventEmitter({
|
||||||
...mockClientMethodsUser(),
|
...mockClientMethodsUser(),
|
||||||
supportsExperimentalThreads: jest.fn().mockReturnValue(true),
|
supportsThreads: jest.fn().mockReturnValue(true),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2015-2022 The Matrix.org Foundation C.I.C.
|
Copyright 2015-2023 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -446,10 +446,16 @@ export interface IStartClientOpts {
|
|||||||
clientWellKnownPollPeriod?: number;
|
clientWellKnownPollPeriod?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* @deprecated use `threadSupport` instead
|
||||||
*/
|
*/
|
||||||
experimentalThreadSupport?: boolean;
|
experimentalThreadSupport?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will organises events in threaded conversations when
|
||||||
|
* a thread relation is encountered
|
||||||
|
*/
|
||||||
|
threadSupport?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
@ -1448,6 +1454,19 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|||||||
this.syncApi = new SyncApi(this, this.clientOpts, this.buildSyncApiOptions());
|
this.syncApi = new SyncApi(this, this.clientOpts, this.buildSyncApiOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.clientOpts.hasOwnProperty("experimentalThreadSupport")) {
|
||||||
|
logger.warn("`experimentalThreadSupport` has been deprecated, use `threadSupport` instead");
|
||||||
|
}
|
||||||
|
|
||||||
|
// If `threadSupport` is omitted and the deprecated `experimentalThreadSupport` has been passed
|
||||||
|
// We should fallback to that value for backwards compatibility purposes
|
||||||
|
if (
|
||||||
|
!this.clientOpts.hasOwnProperty("threadSupport") &&
|
||||||
|
this.clientOpts.hasOwnProperty("experimentalThreadSupport")
|
||||||
|
) {
|
||||||
|
this.clientOpts.threadSupport = this.clientOpts.experimentalThreadSupport;
|
||||||
|
}
|
||||||
|
|
||||||
this.syncApi.sync();
|
this.syncApi.sync();
|
||||||
|
|
||||||
if (this.clientOpts.clientWellKnownPollPeriod !== undefined) {
|
if (this.clientOpts.clientWellKnownPollPeriod !== undefined) {
|
||||||
@ -5498,7 +5517,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|||||||
return timelineSet.getTimelineForEvent(eventId);
|
return timelineSet.getTimelineForEvent(eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timelineSet.thread && this.supportsExperimentalThreads()) {
|
if (timelineSet.thread && this.supportsThreads()) {
|
||||||
return this.getThreadTimeline(timelineSet, eventId);
|
return this.getThreadTimeline(timelineSet, eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5565,7 +5584,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getThreadTimeline(timelineSet: EventTimelineSet, eventId: string): Promise<EventTimeline | undefined> {
|
public async getThreadTimeline(timelineSet: EventTimelineSet, eventId: string): Promise<EventTimeline | undefined> {
|
||||||
if (!this.supportsExperimentalThreads()) {
|
if (!this.supportsThreads()) {
|
||||||
throw new Error("could not get thread timeline: no client support");
|
throw new Error("could not get thread timeline: no client support");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9337,12 +9356,21 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* @deprecated use supportsThreads() instead
|
||||||
*/
|
*/
|
||||||
public supportsExperimentalThreads(): boolean {
|
public supportsExperimentalThreads(): boolean {
|
||||||
|
logger.warn(`supportsExperimentalThreads() is deprecated, use supportThreads() instead`);
|
||||||
return this.clientOpts?.experimentalThreadSupport || false;
|
return this.clientOpts?.experimentalThreadSupport || false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper to determine thread support
|
||||||
|
* @returns a boolean to determine if threads are enabled
|
||||||
|
*/
|
||||||
|
public supportsThreads(): boolean {
|
||||||
|
return this.clientOpts?.threadSupport || false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the summary of a room as defined by an initial version of MSC3266 and implemented in Synapse
|
* Fetches the summary of a room as defined by an initial version of MSC3266 and implemented in Synapse
|
||||||
* Proposed at https://github.com/matrix-org/matrix-doc/pull/3266
|
* Proposed at https://github.com/matrix-org/matrix-doc/pull/3266
|
||||||
@ -9357,14 +9385,20 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* Processes a list of threaded events and adds them to their respective timelines
|
||||||
|
* @param room - the room the adds the threaded events
|
||||||
|
* @param threadedEvents - an array of the threaded events
|
||||||
|
* @param toStartOfTimeline - the direction in which we want to add the events
|
||||||
*/
|
*/
|
||||||
public processThreadEvents(room: Room, threadedEvents: MatrixEvent[], toStartOfTimeline: boolean): void {
|
public processThreadEvents(room: Room, threadedEvents: MatrixEvent[], toStartOfTimeline: boolean): void {
|
||||||
room.processThreadedEvents(threadedEvents, toStartOfTimeline);
|
room.processThreadedEvents(threadedEvents, toStartOfTimeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* Processes a list of thread roots and creates a thread model
|
||||||
|
* @param room - the room to create the threads in
|
||||||
|
* @param threadedEvents - an array of thread roots
|
||||||
|
* @param toStartOfTimeline - the direction
|
||||||
*/
|
*/
|
||||||
public processThreadRoots(room: Room, threadedEvents: MatrixEvent[], toStartOfTimeline: boolean): void {
|
public processThreadRoots(room: Room, threadedEvents: MatrixEvent[], toStartOfTimeline: boolean): void {
|
||||||
room.processThreadRoots(threadedEvents, toStartOfTimeline);
|
room.processThreadRoots(threadedEvents, toStartOfTimeline);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2015 - 2022 The Matrix.org Foundation C.I.C.
|
Copyright 2015 - 2023 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -267,7 +267,6 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
|
|||||||
private txnId?: string;
|
private txnId?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
|
||||||
* A reference to the thread this event belongs to
|
* A reference to the thread this event belongs to
|
||||||
*/
|
*/
|
||||||
private thread?: Thread;
|
private thread?: Thread;
|
||||||
@ -546,7 +545,6 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
|
||||||
* Get the event ID of the thread head
|
* Get the event ID of the thread head
|
||||||
*/
|
*/
|
||||||
public get threadRootId(): string | undefined {
|
public get threadRootId(): string | undefined {
|
||||||
@ -559,7 +557,7 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* A helper to check if an event is a thread's head or not
|
||||||
*/
|
*/
|
||||||
public get isThreadRoot(): boolean {
|
public get isThreadRoot(): boolean {
|
||||||
const threadDetails = this.getServerAggregatedRelation<IThreadBundledRelationship>(THREAD_RELATION_TYPE.name);
|
const threadDetails = this.getServerAggregatedRelation<IThreadBundledRelationship>(THREAD_RELATION_TYPE.name);
|
||||||
@ -1557,7 +1555,8 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* Set the instance of a thread associated with the current event
|
||||||
|
* @param thread - the thread
|
||||||
*/
|
*/
|
||||||
public setThread(thread?: Thread): void {
|
public setThread(thread?: Thread): void {
|
||||||
if (this.thread) {
|
if (this.thread) {
|
||||||
@ -1571,7 +1570,7 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* Get the instance of the thread associated with the current event
|
||||||
*/
|
*/
|
||||||
public getThread(): Thread | undefined {
|
public getThread(): Thread | undefined {
|
||||||
return this.thread;
|
return this.thread;
|
||||||
|
@ -383,7 +383,8 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
public readonly relations = new RelationsContainer(this.client, this);
|
public readonly relations = new RelationsContainer(this.client, this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* A collection of events known by the client
|
||||||
|
* This is not a comprehensive list of the threads that exist in this room
|
||||||
*/
|
*/
|
||||||
private threads = new Map<string, Thread>();
|
private threads = new Map<string, Thread>();
|
||||||
public lastThread?: Thread;
|
public lastThread?: Thread;
|
||||||
@ -483,7 +484,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
return this.threadTimelineSetsPromise;
|
return this.threadTimelineSetsPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.client?.supportsExperimentalThreads()) {
|
if (this.client?.supportsThreads()) {
|
||||||
try {
|
try {
|
||||||
this.threadTimelineSetsPromise = Promise.all([
|
this.threadTimelineSetsPromise = Promise.all([
|
||||||
this.createThreadTimelineSet(),
|
this.createThreadTimelineSet(),
|
||||||
@ -1330,7 +1331,6 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
|
||||||
* Get one of the notification counts for a thread
|
* Get one of the notification counts for a thread
|
||||||
* @param threadId - the root event ID
|
* @param threadId - the root event ID
|
||||||
* @param type - The type of notification count to get. default: 'total'
|
* @param type - The type of notification count to get. default: 'total'
|
||||||
@ -1342,7 +1342,6 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
|
||||||
* Checks if the current room has unread thread notifications
|
* Checks if the current room has unread thread notifications
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
@ -1356,7 +1355,6 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
|
||||||
* Swet one of the notification count for a thread
|
* Swet one of the notification count for a thread
|
||||||
* @param threadId - the root event ID
|
* @param threadId - the root event ID
|
||||||
* @param type - The type of notification count to get. default: 'total'
|
* @param type - The type of notification count to get. default: 'total'
|
||||||
@ -1377,7 +1375,6 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
|
||||||
* @returns the notification count type for all the threads in the room
|
* @returns the notification count type for all the threads in the room
|
||||||
*/
|
*/
|
||||||
public get threadsAggregateNotificationType(): NotificationCountType | null {
|
public get threadsAggregateNotificationType(): NotificationCountType | null {
|
||||||
@ -1393,7 +1390,6 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
|
||||||
* Resets the thread notifications for this room
|
* Resets the thread notifications for this room
|
||||||
*/
|
*/
|
||||||
public resetThreadUnreadNotificationCount(notificationsToKeep?: string[]): void {
|
public resetThreadUnreadNotificationCount(notificationsToKeep?: string[]): void {
|
||||||
@ -1553,14 +1549,16 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* Get the instance of the thread associated with the current event
|
||||||
|
* @param eventId - the ID of the current event
|
||||||
|
* @returns a thread instance if known
|
||||||
*/
|
*/
|
||||||
public getThread(eventId: string): Thread | null {
|
public getThread(eventId: string): Thread | null {
|
||||||
return this.threads.get(eventId) ?? null;
|
return this.threads.get(eventId) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* Get all the known threads in the room
|
||||||
*/
|
*/
|
||||||
public getThreads(): Thread[] {
|
public getThreads(): Thread[] {
|
||||||
return Array.from(this.threads.values());
|
return Array.from(this.threads.values());
|
||||||
@ -1827,7 +1825,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
* Without server support that means fetching as much at once as the server allows us to.
|
* Without server support that means fetching as much at once as the server allows us to.
|
||||||
*/
|
*/
|
||||||
public async fetchRoomThreads(): Promise<void> {
|
public async fetchRoomThreads(): Promise<void> {
|
||||||
if (this.threadsReady || !this.client.supportsExperimentalThreads()) {
|
if (this.threadsReady || !this.client.supportsThreads()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2004,7 +2002,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
shouldLiveInThread: boolean;
|
shouldLiveInThread: boolean;
|
||||||
threadId?: string;
|
threadId?: string;
|
||||||
} {
|
} {
|
||||||
if (!this.client?.supportsExperimentalThreads()) {
|
if (!this.client?.supportsThreads()) {
|
||||||
return {
|
return {
|
||||||
shouldLiveInRoom: true,
|
shouldLiveInRoom: true,
|
||||||
shouldLiveInThread: false,
|
shouldLiveInThread: false,
|
||||||
@ -2073,7 +2071,6 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds events to a thread's timeline. Will fire "Thread.update"
|
* Adds events to a thread's timeline. Will fire "Thread.update"
|
||||||
* @experimental
|
|
||||||
*/
|
*/
|
||||||
public processThreadedEvents(events: MatrixEvent[], toStartOfTimeline: boolean): void {
|
public processThreadedEvents(events: MatrixEvent[], toStartOfTimeline: boolean): void {
|
||||||
events.forEach(this.applyRedaction);
|
events.forEach(this.applyRedaction);
|
||||||
@ -2702,7 +2699,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
// Indices to the events array, for readability
|
// Indices to the events array, for readability
|
||||||
const ROOM = 0;
|
const ROOM = 0;
|
||||||
const THREAD = 1;
|
const THREAD = 1;
|
||||||
if (this.client.supportsExperimentalThreads()) {
|
if (this.client.supportsThreads()) {
|
||||||
const threadRoots = this.findThreadRoots(events);
|
const threadRoots = this.findThreadRoots(events);
|
||||||
return events.reduce(
|
return events.reduce(
|
||||||
(memo, event: MatrixEvent) => {
|
(memo, event: MatrixEvent) => {
|
||||||
|
@ -69,9 +69,6 @@ export function determineFeatureSupport(stable: boolean, unstable: boolean): Fea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @experimental
|
|
||||||
*/
|
|
||||||
export class Thread extends ReadReceipt<EmittedEvents, EventHandlerMap> {
|
export class Thread extends ReadReceipt<EmittedEvents, EventHandlerMap> {
|
||||||
public static hasServerSideSupport = FeatureSupport.None;
|
public static hasServerSideSupport = FeatureSupport.None;
|
||||||
public static hasServerSideListSupport = FeatureSupport.None;
|
public static hasServerSideListSupport = FeatureSupport.None;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2015 - 2022 The Matrix.org Foundation C.I.C.
|
Copyright 2015 - 2023 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -198,7 +198,7 @@ export function defaultClientOpts(opts?: IStoredClientOpts): IStoredClientOpts {
|
|||||||
resolveInvitesToProfiles: false,
|
resolveInvitesToProfiles: false,
|
||||||
pollTimeout: 30 * 1000,
|
pollTimeout: 30 * 1000,
|
||||||
pendingEventOrdering: PendingEventOrdering.Chronological,
|
pendingEventOrdering: PendingEventOrdering.Chronological,
|
||||||
experimentalThreadSupport: false,
|
threadSupport: false,
|
||||||
...opts,
|
...opts,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user