summary refs log tree commit diff
path: root/src/ChatPage.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-26 21:39:00 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-26 21:39:00 +0300
commit15931fc3222beda9555fe996469b0f2059ee328b (patch)
treeae4cd0eb2eef56a9c12c11d9b798ce976bf96970 /src/ChatPage.cc
parentSimplify variant usage (diff)
downloadnheko-15931fc3222beda9555fe996469b0f2059ee328b.tar.xz
Track invites so they can be removed outside of nheko
fixes #213
Diffstat (limited to 'src/ChatPage.cc')
-rw-r--r--src/ChatPage.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/ChatPage.cc b/src/ChatPage.cc
index c8cceabf..8b8b4438 100644
--- a/src/ChatPage.cc
+++ b/src/ChatPage.cc
@@ -493,6 +493,7 @@ ChatPage::syncCompleted(const mtx::responses::Sync &response)
 
         room_list_->sync(roomStates_, roomSettings_);
         room_list_->syncInvites(response.rooms.invite);
+        trackInvites(response.rooms.invite);
 
         view_manager_->sync(response.rooms);
 
@@ -549,6 +550,7 @@ ChatPage::initialSyncCompleted(const mtx::responses::Sync &response)
         // Initialize room list.
         room_list_->setInitialRooms(roomSettings_, roomStates_);
         room_list_->syncInvites(response.rooms.invite);
+        trackInvites(response.rooms.invite);
 
         client_->setNextBatchToken(QString::fromStdString(response.next_batch));
         client_->sync();
@@ -687,7 +689,10 @@ ChatPage::loadStateFromCache()
 
                   // Initialize room list from the restored state and settings.
                   room_list_->setInitialRooms(roomSettings_, roomStates_);
-                  room_list_->syncInvites(cache_->invites());
+
+                  const auto invites = cache_->invites();
+                  room_list_->syncInvites(invites);
+                  trackInvites(invites);
 
                   // Check periodically if the timelines have been loaded.
                   consensusTimer_->start(CONSENSUS_TIMEOUT);
@@ -773,7 +778,9 @@ ChatPage::removeRoom(const QString &room_id)
                 cache_->unmount();
                 cache_->deleteData();
         }
+
         room_list_->removeRoom(room_id, room_id == current_room_);
+        roomInvites_.erase(room_id);
 }
 
 void
@@ -789,6 +796,7 @@ ChatPage::removeInvite(const QString &room_id)
         }
 
         room_list_->removeRoom(room_id, room_id == current_room_);
+        roomInvites_.erase(room_id);
 }
 
 void
@@ -854,6 +862,9 @@ ChatPage::removeLeftRooms(const std::map<std::string, mtx::responses::LeftRoom>
 
                 if (roomStates_.find(room_id) != roomStates_.end())
                         removeRoom(room_id);
+
+                if (roomInvites_.find(room_id) != roomInvites_.end())
+                        removeInvite(room_id);
         }
 }
 
@@ -863,6 +874,9 @@ ChatPage::updateJoinedRooms(const std::map<std::string, mtx::responses::JoinedRo
         for (auto it = rooms.cbegin(); it != rooms.cend(); ++it) {
                 const auto roomid = QString::fromStdString(it->first);
 
+                if (roomInvites_.find(roomid) != roomInvites_.end())
+                        removeInvite(roomid);
+
                 updateTypingUsers(roomid, it->second.ephemeral.typing);
                 updateRoomNotificationCount(roomid,
                                             it->second.unread_notifications.notification_count);