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

@@ -82,7 +82,7 @@ int AccountListModel::rowCount(const QModelIndex& parent) const {
}
void AccountListModel::connectConnectionSignals(Connection* conn) {
connect(conn->user(), &User::avatarChanged, [=] {
connect(conn->user(), &User::avatarChanged, this, [=] {
const auto it = std::find(m_connections.begin(), m_connections.end(), conn);
if (it == m_connections.end()) {
return;

View File

@@ -92,8 +92,8 @@ void Controller::addConnection(Connection* c) {
m_connections.push_back(c);
connect(c, &Connection::syncDone, this, [=] {
static int counter = 0;
if (++counter % 17 == 2) c->saveState();
c->saveState();
c->sync(30000);
});
connect(c, &Connection::loggedOut, this, [=] { dropConnection(c); });

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;