Merge pull request #2736 from matrix-org/travis/upgraded-rooms
Always insert rooms into lists when they get lost
This commit is contained in:
commit
329c1eec1a
1 changed files with 24 additions and 12 deletions
|
@ -429,6 +429,13 @@ class RoomListStore extends Store {
|
||||||
newList.push(entry);
|
newList.push(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pushedEntry && desiredCategoryBoundaryIndex >= 0) {
|
||||||
|
console.warn(`!! Room ${room.roomId} nearly lost: Ran off the end of the list`);
|
||||||
|
console.warn(`!! Inserting at position ${desiredCategoryBoundaryIndex} with category ${category}`);
|
||||||
|
newList.splice(desiredCategoryBoundaryIndex, 0, {room, category});
|
||||||
|
pushedEntry = true;
|
||||||
|
}
|
||||||
|
|
||||||
return pushedEntry;
|
return pushedEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,22 +484,27 @@ class RoomListStore extends Store {
|
||||||
room, category, this._state.lists[key], listsClone[key], lastTimestamp);
|
room, category, this._state.lists[key], listsClone[key], lastTimestamp);
|
||||||
|
|
||||||
if (!pushedEntry) {
|
if (!pushedEntry) {
|
||||||
// Special case invites: they don't really have timelines and can easily get lost when
|
// This should rarely happen: _slotRoomIntoList has several checks which attempt
|
||||||
// the user has multiple pending invites. Pushing them is the least worst option.
|
// to make sure that a room is not lost in the list. If we do lose the room though,
|
||||||
if (listsClone[key].length === 0 || key === "im.vector.fake.invite") {
|
// we shouldn't throw it on the floor and forget about it. Instead, we should insert
|
||||||
listsClone[key].push({room, category});
|
// it somewhere. We'll insert it at the top for a couple reasons: 1) it is probably
|
||||||
insertedIntoTags.push(key);
|
// an important room for the user and 2) if this does happen, we'd want a bug report.
|
||||||
} else {
|
console.warn(`!! Room ${room.roomId} nearly lost: Failed to find a position`);
|
||||||
// In theory, this should never happen
|
console.warn(`!! Inserting at position 0 in the list and flagging as inserted`);
|
||||||
console.warn(`!! Room ${room.roomId} lost: No position available`);
|
console.warn("!! Additional info: ", {
|
||||||
|
category,
|
||||||
|
key,
|
||||||
|
upToIndex: listsClone[key].length,
|
||||||
|
expectedCount: this._state.lists[key].length,
|
||||||
|
});
|
||||||
|
listsClone[key].splice(0, 0, {room, category});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
insertedIntoTags.push(key);
|
insertedIntoTags.push(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Double check that we inserted the room in the right places
|
// Double check that we inserted the room in the right places.
|
||||||
|
// There should never be a discrepancy.
|
||||||
for (const targetTag of targetTags) {
|
for (const targetTag of targetTags) {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
for (const insertedTag of insertedIntoTags) {
|
for (const insertedTag of insertedIntoTags) {
|
||||||
|
|
Loading…
Reference in a new issue