Fix notification issue.

This commit is contained in:
Black Hat
2018-09-10 08:06:32 +08:00
parent f5b24f32b8
commit 13a8d6b889
10 changed files with 47 additions and 83 deletions

View File

@@ -15,9 +15,9 @@ RoomListModel::~RoomListModel() {}
void RoomListModel::setConnection(Connection* connection) {
if (connection == m_connection) return;
m_connection->disconnect(this);
if (!connection) {
qDebug() << "Removing current connection...";
m_connection->disconnect(this);
m_connection = nullptr;
beginResetModel();
m_rooms.clear();
@@ -25,9 +25,10 @@ void RoomListModel::setConnection(Connection* connection) {
return;
}
using QMatrixClient::Room;
m_connection = connection;
for (MatriqueRoom* room : m_rooms) room->disconnect(this);
connect(connection, &Connection::connected, this,
&RoomListModel::doResetModel);
connect(connection, &Connection::invitedRoom, this,
@@ -73,7 +74,7 @@ void RoomListModel::connectRoomSignals(MatriqueRoom* room) {
[=] { refresh(room, {AvatarRole}); });
connect(room, &Room::addedMessages, this,
[=] { refresh(room, {LastEventRole}); });
connect(room, &QMatrixClient::Room::aboutToAddNewMessages, this,
connect(room, &Room::aboutToAddNewMessages, this,
[=](QMatrixClient::RoomEventsRange eventsRange) {
RoomEvent* event = (eventsRange.end() - 1)->get();
if (event->isStateEvent()) return;