Throw if the update cause is unsupported
This commit is contained in:
parent
cc17409943
commit
6b54c3a492
2 changed files with 11 additions and 1 deletions
|
@ -152,6 +152,11 @@ export class ImportanceAlgorithm extends OrderingAlgorithm {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async handleRoomUpdate(room: Room, cause: RoomUpdateCause): Promise<boolean> {
|
public async handleRoomUpdate(room: Room, cause: RoomUpdateCause): Promise<boolean> {
|
||||||
|
// TODO: Handle NewRoom and RoomRemoved
|
||||||
|
if (cause !== RoomUpdateCause.Timeline && cause !== RoomUpdateCause.ReadReceipt) {
|
||||||
|
throw new Error(`Unsupported update cause: ${cause}`);
|
||||||
|
}
|
||||||
|
|
||||||
const category = this.getRoomCategory(room);
|
const category = this.getRoomCategory(room);
|
||||||
if (this.sortingAlgorithm === SortAlgorithm.Manual) {
|
if (this.sortingAlgorithm === SortAlgorithm.Manual) {
|
||||||
return; // Nothing to do here.
|
return; // Nothing to do here.
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
import { SortAlgorithm } from "../models";
|
import { SortAlgorithm } from "../models";
|
||||||
import { sortRoomsWithAlgorithm } from "../tag-sorting";
|
import { sortRoomsWithAlgorithm } from "../tag-sorting";
|
||||||
import { OrderingAlgorithm } from "./OrderingAlgorithm";
|
import { OrderingAlgorithm } from "./OrderingAlgorithm";
|
||||||
import { TagID } from "../../models";
|
import { RoomUpdateCause, TagID } from "../../models";
|
||||||
import { Room } from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +36,11 @@ export class NaturalAlgorithm extends OrderingAlgorithm {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async handleRoomUpdate(room, cause): Promise<boolean> {
|
public async handleRoomUpdate(room, cause): Promise<boolean> {
|
||||||
|
// TODO: Handle NewRoom and RoomRemoved
|
||||||
|
if (cause !== RoomUpdateCause.Timeline && cause !== RoomUpdateCause.ReadReceipt) {
|
||||||
|
throw new Error(`Unsupported update cause: ${cause}`);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Optimize this to avoid useless operations
|
// TODO: Optimize this to avoid useless operations
|
||||||
// For example, we can skip updates to alphabetic (sometimes) and manually ordered tags
|
// For example, we can skip updates to alphabetic (sometimes) and manually ordered tags
|
||||||
this.cachedOrderedRooms = await sortRoomsWithAlgorithm(this.cachedOrderedRooms, this.tagId, this.sortingAlgorithm);
|
this.cachedOrderedRooms = await sortRoomsWithAlgorithm(this.cachedOrderedRooms, this.tagId, this.sortingAlgorithm);
|
||||||
|
|
Loading…
Reference in a new issue