From a2dab31fd6ca3728175716df2cff2dda448b2914 Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Sun, 14 Feb 2021 13:01:16 +0530 Subject: [PATCH 1/3] Fix two room leaving related bugs and add invite user on clicking invite --- src/RoomList.cpp | 11 +++++++++-- src/dialogs/InviteUsers.cpp | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/RoomList.cpp b/src/RoomList.cpp index 764a8e42..67a7ac40 100644 --- a/src/RoomList.cpp +++ b/src/RoomList.cpp @@ -106,6 +106,10 @@ void RoomList::removeRoom(const QString &room_id, bool reset) { auto roomIt = rooms_.find(room_id); + if (roomIt == rooms_.end()) { + return; + } + for (auto roomSortIt = rooms_sort_cache_.begin(); roomSortIt != rooms_sort_cache_.end(); ++roomSortIt) { if (roomIt->second == *roomSortIt) { @@ -523,8 +527,11 @@ RoomList::firstRoom() const auto item = qobject_cast(contentsLayout_->itemAt(i)->widget()); if (item) { - return std::pair>( - item->roomId(), rooms_.at(item->roomId())); + auto topRoom = rooms_.find(item->roomId()); + if (topRoom != rooms_.end()) { + return std::pair>( + item->roomId(), topRoom->second); + } } } diff --git a/src/dialogs/InviteUsers.cpp b/src/dialogs/InviteUsers.cpp index f85adb8f..2de1d20f 100644 --- a/src/dialogs/InviteUsers.cpp +++ b/src/dialogs/InviteUsers.cpp @@ -65,6 +65,10 @@ InviteUsers::InviteUsers(QWidget *parent) connect(inviteeInput_, &TextField::returnPressed, this, &InviteUsers::addUser); connect(confirmBtn_, &QPushButton::clicked, [this]() { + if (!inviteeInput_->text().isEmpty()) { + addUser(); + } + emit sendInvites(invitedUsers()); inviteeInput_->clear(); From f35e8264859318f170c2cb4aa55ce765fb3bad3f Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Sun, 14 Feb 2021 19:57:29 +0530 Subject: [PATCH 2/3] Fix room list updating on adding to hidden tag or removing tag --- src/CommunitiesList.cpp | 3 +++ src/CommunitiesList.h | 1 + 2 files changed, 4 insertions(+) diff --git a/src/CommunitiesList.cpp b/src/CommunitiesList.cpp index 77e6368a..8bc71d91 100644 --- a/src/CommunitiesList.cpp +++ b/src/CommunitiesList.cpp @@ -65,6 +65,7 @@ CommunitiesList::setCommunities(const mtx::responses::JoinedGroups &response) addCommunity(group); communities_["world"]->setPressedState(true); + selectedCommunity_ = "world"; emit communityChanged("world"); sortEntries(); } @@ -74,6 +75,7 @@ CommunitiesList::syncTags(const std::map &info) { for (const auto &room : info) setTagsForRoom(room.first, room.second.tags); + emit communityChanged(selectedCommunity_); sortEntries(); } @@ -231,6 +233,7 @@ CommunitiesList::highlightSelectedCommunity(const QString &community_id) return; } + selectedCommunity_ = community_id; emit communityChanged(community_id); for (const auto &community : communities_) { diff --git a/src/CommunitiesList.h b/src/CommunitiesList.h index d62beb8d..5113e7ed 100644 --- a/src/CommunitiesList.h +++ b/src/CommunitiesList.h @@ -53,6 +53,7 @@ private: return communities_.find(id) != communities_.end(); } + QString selectedCommunity_; QVBoxLayout *topLayout_; QVBoxLayout *contentsLayout_; QScrollArea *scrollArea_; From 96028f00a5d1510c2db6b81d536fb8e8249a3272 Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Tue, 16 Feb 2021 01:00:32 +0530 Subject: [PATCH 3/3] trim invite input text --- src/dialogs/InviteUsers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dialogs/InviteUsers.cpp b/src/dialogs/InviteUsers.cpp index 2de1d20f..8f1097fa 100644 --- a/src/dialogs/InviteUsers.cpp +++ b/src/dialogs/InviteUsers.cpp @@ -65,7 +65,7 @@ InviteUsers::InviteUsers(QWidget *parent) connect(inviteeInput_, &TextField::returnPressed, this, &InviteUsers::addUser); connect(confirmBtn_, &QPushButton::clicked, [this]() { - if (!inviteeInput_->text().isEmpty()) { + if (!inviteeInput_->text().trimmed().isEmpty()) { addUser(); }