Switch to room after joining invite

This commit is contained in:
Nicolas Werner 2021-07-13 03:13:52 +02:00
parent 0a4e95a1db
commit 47899ee7ed
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -6,6 +6,7 @@
#include "Cache_p.h" #include "Cache_p.h"
#include "ChatPage.h" #include "ChatPage.h"
#include "Logging.h"
#include "MatrixClient.h" #include "MatrixClient.h"
#include "MxcImageProvider.h" #include "MxcImageProvider.h"
#include "TimelineModel.h" #include "TimelineModel.h"
@ -363,6 +364,13 @@ RoomlistModel::addRoom(const QString &room_id, bool suppressInsertNotification)
roomids.push_back(room_id); roomids.push_back(room_id);
} }
if ((wasInvite || wasPreview) && currentRoomPreview_ &&
currentRoomPreview_->roomid() == room_id) {
currentRoom_ = models.value(room_id);
currentRoomPreview_.reset();
emit currentRoomChanged();
}
for (auto p : previewsToAdd) { for (auto p : previewsToAdd) {
previewedRooms.insert(p, std::nullopt); previewedRooms.insert(p, std::nullopt);
roomids.push_back(std::move(p)); roomids.push_back(std::move(p));
@ -557,15 +565,8 @@ void
RoomlistModel::acceptInvite(QString roomid) RoomlistModel::acceptInvite(QString roomid)
{ {
if (invites.contains(roomid)) { if (invites.contains(roomid)) {
auto idx = roomidToIndex(roomid); // Don't remove invite yet, so that we can switch to it
ChatPage::instance()->joinRoom(roomid);
if (idx != -1) {
beginRemoveRows(QModelIndex(), idx, idx);
roomids.erase(roomids.begin() + idx);
invites.remove(roomid);
endRemoveRows();
ChatPage::instance()->joinRoom(roomid);
}
} }
} }
void void