compare(): Add checks for 'ph-123' room IDs

These will be used to place placeholders correctly.
This commit is contained in:
Kegan Dougal 2021-11-30 15:35:29 +00:00
parent 7dc8648fec
commit 4f7468a95a

View file

@ -159,8 +159,14 @@ export class Sync3 {
if (roomIdA === roomIdB) {
return 0;
}
const indexA = this.roomIdToRoomIndex[roomIdA];
const indexB = this.roomIdToRoomIndex[roomIdB];
let indexA = this.roomIdToRoomIndex[roomIdA];
let indexB = this.roomIdToRoomIndex[roomIdB];
if (indexA === undefined && roomIdA.startsWith("ph-")) {
indexA = Number(roomIdA.substr(3));
}
if (indexB === undefined && roomIdB.startsWith("ph-")) {
indexB = Number(roomIdB.substr(3));
}
if (indexA === undefined || indexB === undefined) {
console.error("sync3 cannot compare: missing indices for rooms", roomIdA, roomIdB, indexA, indexB);
}