Skip to content
Snippets Groups Projects
Verified Commit 49b313e3 authored by tastytea's avatar tastytea Committed by Nicolas Werner
Browse files

Hidden events: Make save-function reusable for global account data

parent f7ca41bc
No related branches found
No related tags found
No related merge requests found
......@@ -121,7 +121,7 @@ ApplicationWindow {
if (!toggleSticker.checked) {
events.push("m.sticker");
}
roomSettings.saveHiddenEventsSettings(events);
roomSettings.saveHiddenEventsSettings(events, roomSettings.roomId);
hiddenEventsDialog.close();
}
......
......@@ -427,9 +427,8 @@ RoomSettings::openEditModal()
}
void
RoomSettings::saveHiddenEventsSettings(const QSet<QString> events)
RoomSettings::saveHiddenEventsSettings(const QSet<QString> &events, const QString &roomId)
{
// TODO: Make this reusable for global account settings.
mtx::events::account_data::nheko_extensions::HiddenEvents hiddenEvents;
hiddenEvents.hidden_event_types = {
EventType::Reaction, EventType::CallCandidates, EventType::Unsupported};
......@@ -438,12 +437,21 @@ RoomSettings::saveHiddenEventsSettings(const QSet<QString> events)
mtx::events::getEventType(event.toStdString()));
}
const auto roomid = roomid_.toStdString();
http::client()->put_room_account_data(roomid, hiddenEvents, [&roomid](mtx::http::RequestErr e) {
if (e) {
nhlog::net()->error("Failed to update room account data in {}: {}", roomid, *e);
}
});
if (!roomId.isEmpty()) {
const auto rid = roomId.toStdString();
http::client()->put_room_account_data(rid, hiddenEvents, [&rid](mtx::http::RequestErr e) {
if (e) {
nhlog::net()->error(
"Failed to update room account data with hidden events in {}: {}", rid, *e);
}
});
} else {
http::client()->put_account_data(hiddenEvents, [](mtx::http::RequestErr e) {
if (e) {
nhlog::net()->error("Failed to update account data with hidden events: {}", *e);
}
});
}
}
void
......
......@@ -109,7 +109,8 @@ public:
Q_INVOKABLE void enableEncryption();
Q_INVOKABLE void updateAvatar();
Q_INVOKABLE void openEditModal();
Q_INVOKABLE void saveHiddenEventsSettings(QSet<QString> events);
Q_INVOKABLE void
saveHiddenEventsSettings(const QSet<QString> &events, const QString &roomId = {});
Q_INVOKABLE void changeAccessRules(int index);
Q_INVOKABLE void changeNotifications(int currentIndex);
Q_INVOKABLE bool eventHidden(QString event) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment