diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-04-22 11:27:00 +0300 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-04-22 11:27:00 +0300 |
commit | 6d0bc0c05ee5e8ac9146ffa4808f6a013d1c7438 (patch) | |
tree | 104e4697dce16695e374429ae7e8629d91a7e381 /src/ChatPage.cc | |
parent | Initialize views before room list (diff) | |
download | nheko-6d0bc0c05ee5e8ac9146ffa4808f6a013d1c7438.tar.xz |
Strip whitespace from room names for QuickSwitcher
Diffstat (limited to 'src/ChatPage.cc')
-rw-r--r-- | src/ChatPage.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/ChatPage.cc b/src/ChatPage.cc index ff59471f..ae3079a3 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -624,6 +624,11 @@ ChatPage::updateOwnCommunitiesInfo(const QList<QString> &own_communities) void ChatPage::changeTopRoomInfo(const QString &room_id) { + if (room_id.isEmpty()) { + qWarning() << "can't switch to empty room_id"; + return; + } + try { auto room_info = cache_->getRoomInfo({room_id.toStdString()}); @@ -640,12 +645,11 @@ ChatPage::changeTopRoomInfo(const QString &room_id) top_bar_->updateRoomAvatar(roomAvatars_[room_id].toImage()); else top_bar_->updateRoomAvatarFromName(name); + + current_room_ = room_id; } catch (const lmdb::error &e) { - qWarning() << "failed to change top bar room info" - << QString::fromStdString(e.what()); + qWarning() << "failed to change top bar room info" << e.what(); } - - current_room_ = room_id; } void @@ -712,12 +716,11 @@ ChatPage::showQuickSwitcher() quickSwitcherModal_->setColor(QColor(30, 30, 30, 170)); } - std::map<QString, QString> rooms; - try { - auto info = cache_->roomInfo(); + std::map<QString, QString> rooms; + auto info = cache_->roomInfo(false); for (auto it = info.begin(); it != info.end(); ++it) - rooms.emplace(QString::fromStdString(it.value().name), it.key()); + rooms.emplace(QString::fromStdString(it.value().name).trimmed(), it.key()); quickSwitcher_->setRoomList(rooms); quickSwitcherModal_->show(); } catch (const lmdb::error &e) { |