Remove the lock around the algorithm

This isn't needed
This commit is contained in:
Travis Ralston 2020-07-06 19:37:57 -06:00
parent 70e5da677b
commit 34bd59c151

View file

@ -33,7 +33,6 @@ import { FILTER_CHANGED, FilterPriority, IFilterCondition } from "../filters/IFi
import { EffectiveMembership, getEffectiveMembership, splitRoomsByMembership } from "../membership";
import { OrderingAlgorithm } from "./list-ordering/OrderingAlgorithm";
import { getListAlgorithmInstance } from "./list-ordering";
import AwaitLock from "await-lock";
// TODO: Add locking support to avoid concurrent writes? https://github.com/vector-im/riot-web/issues/14235
@ -68,7 +67,6 @@ export class Algorithm extends EventEmitter {
} = {};
private allowedByFilter: Map<IFilterCondition, Room[]> = new Map<IFilterCondition, Room[]>();
private allowedRoomsByFilters: Set<Room> = new Set<Room>();
private readonly lock = new AwaitLock();
public constructor() {
super();
@ -643,9 +641,6 @@ export class Algorithm extends EventEmitter {
public async handleRoomUpdate(room: Room, cause: RoomUpdateCause): Promise<boolean> {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`Handle room update for ${room.roomId} called with cause ${cause}`);
try {
await this.lock.acquireAsync();
if (!this.algorithms) throw new Error("Not ready: no algorithms to determine tags from");
const isSticky = this._stickyRoom && this._stickyRoom.room === room;
@ -728,9 +723,7 @@ export class Algorithm extends EventEmitter {
};
} else {
// We have to clear the lock as the sticky room change will trigger updates.
this.lock.release();
await this.setStickyRoomAsync(room);
await this.lock.acquireAsync();
}
}
}
@ -789,8 +782,5 @@ export class Algorithm extends EventEmitter {
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
console.log(`[RoomListDebug] Finished handling ${room.roomId} with cause ${cause} (changed=${changed})`);
return changed;
} finally {
this.lock.release();
}
}
}