summary refs log tree commit diff
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-18 21:43:58 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-18 21:43:58 +0300
commit9eb1c496a0911a8c3dcab0a4e103440ba3c1e7ec (patch)
tree7c616455da04bbb4760a4faff942acfd297e2ad7
parentRefresh the room info on the top bar after sync (diff)
downloadnheko-9eb1c496a0911a8c3dcab0a4e103440ba3c1e7ec.tar.xz
Retrieve the current room state from cache when the edit modal opens
-rw-r--r--include/dialogs/RoomSettings.hpp2
-rw-r--r--src/dialogs/RoomSettings.cpp22
2 files changed, 16 insertions, 8 deletions
diff --git a/include/dialogs/RoomSettings.hpp b/include/dialogs/RoomSettings.hpp

index 1434eee6..375a531e 100644 --- a/include/dialogs/RoomSettings.hpp +++ b/include/dialogs/RoomSettings.hpp
@@ -93,6 +93,8 @@ private: void setAvatar(const QImage &img) { avatarImg_ = img; } void setupEditButton(); + //! Retrieve the current room information from cache. + void retrieveRoomInfo(); //! Whether the user would be able to change the name or the topic of the room. bool hasEditRights_ = true; diff --git a/src/dialogs/RoomSettings.cpp b/src/dialogs/RoomSettings.cpp
index ff784158..4d2f304b 100644 --- a/src/dialogs/RoomSettings.cpp +++ b/src/dialogs/RoomSettings.cpp
@@ -182,14 +182,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) , room_id_{std::move(room_id)} { setMaximumWidth(420); - - try { - info_ = cache::client()->singleRoomInfo(room_id_.toStdString()); - - setAvatar(QImage::fromData(cache::client()->image(info_.avatar_url))); - } catch (const lmdb::error &e) { - qWarning() << "failed to retrieve room info from cache" << room_id; - } + retrieveRoomInfo(); constexpr int SettingsMargin = 2; @@ -299,6 +292,8 @@ RoomSettings::setupEditButton() editFieldsBtn_->setIconSize(QSize(iconSize, iconSize)); connect(editFieldsBtn_, &QPushButton::clicked, this, [this]() { + retrieveRoomInfo(); + auto modal = new EditModal(room_id_, this->parentWidget()); modal->setFields(QString::fromStdString(info_.name), QString::fromStdString(info_.topic)); @@ -312,6 +307,17 @@ RoomSettings::setupEditButton() } void +RoomSettings::retrieveRoomInfo() +{ + try { + info_ = cache::client()->singleRoomInfo(room_id_.toStdString()); + setAvatar(QImage::fromData(cache::client()->image(info_.avatar_url))); + } catch (const lmdb::error &e) { + qWarning() << "failed to retrieve room info from cache" << room_id_; + } +} + +void RoomSettings::saveSettings() { // TODO: Save access changes to the room