Fix off-by-1 in insertRows when loading room list from initial sync

This commit is contained in:
Nicolas Werner 2021-07-12 01:07:10 +02:00
parent 68851ee5aa
commit 801af1864c
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
2 changed files with 4 additions and 3 deletions

View File

@ -162,7 +162,7 @@ appimage-amd64:
before_script:
# app build requirements
- apt-get update && apt-get install -y software-properties-common
- add-apt-repository ppa:beineri/opt-qt-5.15.2-xenial -y
- add-apt-repository ppa:beineri/opt-qt-5.15.2-bionic -y
- apt-get update
- apt-get install -y git wget curl

View File

@ -348,7 +348,7 @@ RoomlistModel::addRoom(const QString &room_id, bool suppressInsertNotification)
beginInsertRows(QModelIndex(),
(int)roomids.size(),
(int)(roomids.size() + previewsToAdd.size() -
((wasInvite || wasPreview) ? 0 : 1)));
((wasInvite || wasPreview) ? 1 : 0)));
models.insert(room_id, std::move(newRoom));
if (wasInvite) {
@ -368,7 +368,8 @@ RoomlistModel::addRoom(const QString &room_id, bool suppressInsertNotification)
roomids.push_back(std::move(p));
}
if (!suppressInsertNotification && !wasInvite)
if (!suppressInsertNotification &&
((!wasInvite && !wasPreview) || !previewedRooms.empty()))
endInsertRows();
}
}