mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 13:08:48 +03:00
Hidden events: Make reusable read function
This commit is contained in:
parent
72cfb06208
commit
7ebced29e9
2 changed files with 16 additions and 9 deletions
|
@ -229,15 +229,7 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
|
||||||
}
|
}
|
||||||
emit accessJoinRulesChanged();
|
emit accessJoinRulesChanged();
|
||||||
|
|
||||||
if (auto hiddenEvents = cache::client()->getAccountData(
|
readHiddenEventsSettings(roomid_);
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
|
@ -682,3 +674,17 @@ RoomSettings::eventHidden(const QString event) const
|
||||||
{
|
{
|
||||||
return hiddenEvents_.contains(event);
|
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,
|
void updateAccessRules(const std::string &room_id,
|
||||||
const mtx::events::state::JoinRules &,
|
const mtx::events::state::JoinRules &,
|
||||||
const mtx::events::state::GuestAccess &);
|
const mtx::events::state::GuestAccess &);
|
||||||
|
void readHiddenEventsSettings(const QString &roomId = {});
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString roomid_;
|
QString roomid_;
|
||||||
|
|
Loading…
Reference in a new issue