Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:matrix-org/matrix-js-sdk into t3…
Browse files Browse the repository at this point in the history
…chguy/fix/21466
  • Loading branch information
t3chguy committed Mar 23, 2022
2 parents 37cdb93 + d0b9648 commit 8fd3d24
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 728 deletions.
1 change: 1 addition & 0 deletions src/@types/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const RoomCreateTypeField = "type";

export enum RoomType {
Space = "m.space",
UnstableCall = "org.matrix.msc3417.call",
}

/**
Expand Down
406 changes: 1 addition & 405 deletions src/client.ts

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export * from "./errors";
export * from "./models/beacon";
export * from "./models/event";
export * from "./models/room";
export * from "./models/group";
export * from "./models/event-timeline";
export * from "./models/event-timeline-set";
export * from "./models/room-member";
Expand Down
100 changes: 0 additions & 100 deletions src/models/group.js

This file was deleted.

39 changes: 29 additions & 10 deletions src/models/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,6 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>
RoomEvent.TimelineReset,
]);

if (this.client?.supportsExperimentalThreads) {
Promise.all([
this.createThreadTimelineSet(),
this.createThreadTimelineSet(ThreadFilterType.My),
]).then((timelineSets) => {
this.threadsTimelineSets.push(...timelineSets);
});
}

this.fixUpLegacyTimelineFields();

if (this.opts.pendingEventOrdering === PendingEventOrdering.Detached) {
Expand All @@ -382,6 +373,26 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>
}
}

private threadTimelineSetsPromise: Promise<[EventTimelineSet, EventTimelineSet]> | null = null;
public async createThreadsTimelineSets(): Promise<[EventTimelineSet, EventTimelineSet]> {
if (this.threadTimelineSetsPromise) {
return this.threadTimelineSetsPromise;
}

if (this.client?.supportsExperimentalThreads) {
try {
this.threadTimelineSetsPromise = Promise.all([
this.createThreadTimelineSet(),
this.createThreadTimelineSet(ThreadFilterType.My),
]);
const timelineSets = await this.threadTimelineSetsPromise;
this.threadsTimelineSets.push(...timelineSets);
} catch (e) {
this.threadTimelineSetsPromise = null;
}
}
}

/**
* Bulk decrypt critical events in a room
*
Expand Down Expand Up @@ -2414,7 +2425,7 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>

/**
* Returns the type of the room from the `m.room.create` event content or undefined if none is set
* @returns {?string} the type of the room. Currently only RoomType.Space is known.
* @returns {?string} the type of the room.
*/
public getType(): RoomType | string | undefined {
const createEvent = this.currentState.getStateEvents(EventType.RoomCreate, "");
Expand All @@ -2436,6 +2447,14 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>
return this.getType() === RoomType.Space;
}

/**
* Returns whether the room is a call-room as defined by MSC3417.
* @returns {boolean} true if the room's type is RoomType.UnstableCall
*/
public isCallRoom(): boolean {
return this.getType() === RoomType.UnstableCall;
}

/**
* This is an internal method. Calculates the name of the room from the current
* room state.
Expand Down
26 changes: 1 addition & 25 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@ limitations under the License.
*/

import { EventType } from "../@types/event";
import { Group } from "../models/group";
import { Room } from "../models/room";
import { User } from "../models/user";
import { IEvent, MatrixEvent } from "../models/event";
import { Filter } from "../filter";
import { RoomSummary } from "../models/room-summary";
import { IMinimalEvent, IGroups, IRooms, ISyncResponse } from "../sync-accumulator";
import { IMinimalEvent, IRooms, ISyncResponse } from "../sync-accumulator";
import { IStartClientOpts } from "../client";

export interface ISavedSync {
nextBatch: string;
roomsData: IRooms;
groupsData: IGroups;
accountData: IMinimalEvent[];
}

Expand All @@ -53,28 +51,6 @@ export interface IStore {
*/
setSyncToken(token: string): void;

/**
* No-op.
* @param {Group} group
* @deprecated groups/communities never made it to the spec and support for them is being discontinued.
*/
storeGroup(group: Group): void;

/**
* No-op.
* @param {string} groupId
* @return {null}
* @deprecated groups/communities never made it to the spec and support for them is being discontinued.
*/
getGroup(groupId: string): Group | null;

/**
* No-op.
* @return {Array} An empty array.
* @deprecated groups/communities never made it to the spec and support for them is being discontinued.
*/
getGroups(): Group[];

/**
* No-op.
* @param {Room} room
Expand Down
6 changes: 1 addition & 5 deletions src/store/indexeddb-local-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export class LocalIndexedDBStoreBackend implements IIndexedDBBackend {
this.syncAccumulator.accumulate({
next_batch: syncData.nextBatch,
rooms: syncData.roomsData,
groups: syncData.groupsData,
account_data: {
events: accountData,
},
Expand Down Expand Up @@ -405,21 +404,19 @@ export class LocalIndexedDBStoreBackend implements IIndexedDBBackend {
await Promise.all([
this.persistUserPresenceEvents(userTuples),
this.persistAccountData(syncData.accountData),
this.persistSyncData(syncData.nextBatch, syncData.roomsData, syncData.groupsData),
this.persistSyncData(syncData.nextBatch, syncData.roomsData),
]);
}

/**
* Persist rooms /sync data along with the next batch token.
* @param {string} nextBatch The next_batch /sync value.
* @param {Object} roomsData The 'rooms' /sync data from a SyncAccumulator
* @param {Object} groupsData The 'groups' /sync data from a SyncAccumulator
* @return {Promise} Resolves if the data was persisted.
*/
private persistSyncData(
nextBatch: string,
roomsData: ISyncResponse["rooms"],
groupsData: ISyncResponse["groups"],
): Promise<void> {
logger.log("Persisting sync data up to", nextBatch);
return utils.promiseTry<void>(() => {
Expand All @@ -429,7 +426,6 @@ export class LocalIndexedDBStoreBackend implements IIndexedDBBackend {
clobber: "-", // constant key so will always clobber
nextBatch,
roomsData,
groupsData,
}); // put == UPSERT
return txnAsPromise(txn).then();
});
Expand Down
30 changes: 0 additions & 30 deletions src/store/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ limitations under the License.
*/

import { EventType } from "../@types/event";
import { Group } from "../models/group";
import { Room } from "../models/room";
import { User } from "../models/user";
import { IEvent, MatrixEvent } from "../models/event";
Expand Down Expand Up @@ -53,7 +52,6 @@ export interface IOpts {
*/
export class MemoryStore implements IStore {
private rooms: Record<string, Room> = {}; // roomId: Room
private groups: Record<string, Group> = {}; // groupId: Group
private users: Record<string, User> = {}; // userId: User
private syncToken: string = null;
// userId: {
Expand Down Expand Up @@ -90,34 +88,6 @@ export class MemoryStore implements IStore {
this.syncToken = token;
}

/**
* Store the given room.
* @param {Group} group The group to be stored
* @deprecated groups/communities never made it to the spec and support for them is being discontinued.
*/
public storeGroup(group: Group) {
this.groups[group.groupId] = group;
}

/**
* Retrieve a group by its group ID.
* @param {string} groupId The group ID.
* @return {Group} The group or null.
* @deprecated groups/communities never made it to the spec and support for them is being discontinued.
*/
public getGroup(groupId: string): Group | null {
return this.groups[groupId] || null;
}

/**
* Retrieve all known groups.
* @return {Group[]} A list of groups, which may be empty.
* @deprecated groups/communities never made it to the spec and support for them is being discontinued.
*/
public getGroups(): Group[] {
return Object.values(this.groups);
}

/**
* Store the given room.
* @param {Room} room The room to be stored. All properties must be stored.
Expand Down
27 changes: 0 additions & 27 deletions src/store/stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ limitations under the License.
*/

import { EventType } from "../@types/event";
import { Group } from "../models/group";
import { Room } from "../models/room";
import { User } from "../models/user";
import { IEvent, MatrixEvent } from "../models/event";
Expand Down Expand Up @@ -58,32 +57,6 @@ export class StubStore implements IStore {
this.fromToken = token;
}

/**
* No-op.
* @param {Group} group
* @deprecated groups/communities never made it to the spec and support for them is being discontinued.
*/
public storeGroup(group: Group) {}

/**
* No-op.
* @param {string} groupId
* @return {null}
* @deprecated groups/communities never made it to the spec and support for them is being discontinued.
*/
public getGroup(groupId: string): Group | null {
return null;
}

/**
* No-op.
* @return {Array} An empty array.
* @deprecated groups/communities never made it to the spec and support for them is being discontinued.
*/
public getGroups(): Group[] {
return [];
}

/**
* No-op.
* @param {Room} room
Expand Down
Loading

0 comments on commit 8fd3d24

Please sign in to comment.