Hidden events: Make reusable read function

pull/891/head
tastytea 3 years ago committed by Nicolas Werner
parent 72cfb06208
commit 7ebced29e9
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 24
      src/ui/RoomSettings.cpp
  2. 1
      src/ui/RoomSettings.h

@ -229,15 +229,7 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
}
emit accessJoinRulesChanged();
if (auto hiddenEvents = cache::client()->getAccountData(
mtx::events::EventType::NhekoHiddenEvents, roomid_.toStdString())) {
if (auto tmp = std::get_if<mtx::events::EphemeralEvent<
mtx::events::account_data::nheko_extensions::HiddenEvents>>(&*hiddenEvents)) {
for (const auto event : tmp->content.hidden_event_types) {
hiddenEvents_.insert(mtx::events::to_string(event).data());
}
}
}
readHiddenEventsSettings(roomid_);
}
QString
@ -682,3 +674,17 @@ RoomSettings::eventHidden(const QString event) const
{
return hiddenEvents_.contains(event);
}
void
RoomSettings::readHiddenEventsSettings(const QString &roomId)
{
if (auto hiddenEvents = cache::client()->getAccountData(
mtx::events::EventType::NhekoHiddenEvents, roomId.toStdString())) {
if (auto tmp = std::get_if<mtx::events::EphemeralEvent<
mtx::events::account_data::nheko_extensions::HiddenEvents>>(&*hiddenEvents)) {
for (const auto event : tmp->content.hidden_event_types) {
hiddenEvents_.insert(mtx::events::to_string(event).data());
}
}
}
}

@ -134,6 +134,7 @@ private:
void updateAccessRules(const std::string &room_id,
const mtx::events::state::JoinRules &,
const mtx::events::state::GuestAccess &);
void readHiddenEventsSettings(const QString &roomId = {});
private:
QString roomid_;

Loading…
Cancel
Save