mirror of https://github.com/vector-im/riot-web
parent
70e5da677b
commit
34bd59c151
|
@ -33,7 +33,6 @@ import { FILTER_CHANGED, FilterPriority, IFilterCondition } from "../filters/IFi
|
||||||
import { EffectiveMembership, getEffectiveMembership, splitRoomsByMembership } from "../membership";
|
import { EffectiveMembership, getEffectiveMembership, splitRoomsByMembership } from "../membership";
|
||||||
import { OrderingAlgorithm } from "./list-ordering/OrderingAlgorithm";
|
import { OrderingAlgorithm } from "./list-ordering/OrderingAlgorithm";
|
||||||
import { getListAlgorithmInstance } from "./list-ordering";
|
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
|
// 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 allowedByFilter: Map<IFilterCondition, Room[]> = new Map<IFilterCondition, Room[]>();
|
||||||
private allowedRoomsByFilters: Set<Room> = new Set<Room>();
|
private allowedRoomsByFilters: Set<Room> = new Set<Room>();
|
||||||
private readonly lock = new AwaitLock();
|
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
super();
|
super();
|
||||||
|
@ -643,9 +641,6 @@ export class Algorithm extends EventEmitter {
|
||||||
public async handleRoomUpdate(room: Room, cause: RoomUpdateCause): Promise<boolean> {
|
public async handleRoomUpdate(room: Room, cause: RoomUpdateCause): Promise<boolean> {
|
||||||
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
|
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
|
||||||
console.log(`Handle room update for ${room.roomId} called with cause ${cause}`);
|
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");
|
if (!this.algorithms) throw new Error("Not ready: no algorithms to determine tags from");
|
||||||
|
|
||||||
const isSticky = this._stickyRoom && this._stickyRoom.room === room;
|
const isSticky = this._stickyRoom && this._stickyRoom.room === room;
|
||||||
|
@ -728,9 +723,7 @@ export class Algorithm extends EventEmitter {
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// We have to clear the lock as the sticky room change will trigger updates.
|
// We have to clear the lock as the sticky room change will trigger updates.
|
||||||
this.lock.release();
|
|
||||||
await this.setStickyRoomAsync(room);
|
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
|
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
|
||||||
console.log(`[RoomListDebug] Finished handling ${room.roomId} with cause ${cause} (changed=${changed})`);
|
console.log(`[RoomListDebug] Finished handling ${room.roomId} with cause ${cause} (changed=${changed})`);
|
||||||
return changed;
|
return changed;
|
||||||
} finally {
|
|
||||||
this.lock.release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue