Make missing rooms throw instead

For now at least. We shouldn't encounter this case until we get around to adding support for newly-joined rooms.
pull/21833/head
Travis Ralston 2020-05-07 16:38:14 -06:00
parent e1fab9a5b6
commit 4a0d14e322
1 changed files with 1 additions and 4 deletions

View File

@ -207,15 +207,12 @@ export class ImportanceAlgorithm extends Algorithm {
const taggedRooms = this.cached[tag];
const indicies = this.indices[tag];
let roomIdx = taggedRooms.indexOf(room);
let inList = true;
if (roomIdx === -1) {
console.warn(`Degrading performance to find missing room in "${tag}": ${room.roomId}`);
roomIdx = taggedRooms.findIndex(r => r.roomId === room.roomId);
}
if (roomIdx === -1) {
console.warn(`Room ${room.roomId} has no index in ${tag} - assuming end of list`);
roomIdx = taggedRooms.length;
inList = false; // used so we don't splice the dead room out
throw new Error(`Room ${room.roomId} has no index in ${tag}`);
}
// Try to avoid doing array operations if we don't have to: only move rooms within