mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
Hidden events: Make save-function reusable for global account data
This commit is contained in:
parent
f7ca41bc49
commit
49b313e3b8
3 changed files with 19 additions and 10 deletions
|
@ -121,7 +121,7 @@ ApplicationWindow {
|
||||||
if (!toggleSticker.checked) {
|
if (!toggleSticker.checked) {
|
||||||
events.push("m.sticker");
|
events.push("m.sticker");
|
||||||
}
|
}
|
||||||
roomSettings.saveHiddenEventsSettings(events);
|
roomSettings.saveHiddenEventsSettings(events, roomSettings.roomId);
|
||||||
|
|
||||||
hiddenEventsDialog.close();
|
hiddenEventsDialog.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -427,9 +427,8 @@ RoomSettings::openEditModal()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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;
|
mtx::events::account_data::nheko_extensions::HiddenEvents hiddenEvents;
|
||||||
hiddenEvents.hidden_event_types = {
|
hiddenEvents.hidden_event_types = {
|
||||||
EventType::Reaction, EventType::CallCandidates, EventType::Unsupported};
|
EventType::Reaction, EventType::CallCandidates, EventType::Unsupported};
|
||||||
|
@ -438,12 +437,21 @@ RoomSettings::saveHiddenEventsSettings(const QSet<QString> events)
|
||||||
mtx::events::getEventType(event.toStdString()));
|
mtx::events::getEventType(event.toStdString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto roomid = roomid_.toStdString();
|
if (!roomId.isEmpty()) {
|
||||||
http::client()->put_room_account_data(roomid, hiddenEvents, [&roomid](mtx::http::RequestErr e) {
|
const auto rid = roomId.toStdString();
|
||||||
if (e) {
|
http::client()->put_room_account_data(rid, hiddenEvents, [&rid](mtx::http::RequestErr e) {
|
||||||
nhlog::net()->error("Failed to update room account data in {}: {}", roomid, *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
|
void
|
||||||
|
|
|
@ -109,7 +109,8 @@ public:
|
||||||
Q_INVOKABLE void enableEncryption();
|
Q_INVOKABLE void enableEncryption();
|
||||||
Q_INVOKABLE void updateAvatar();
|
Q_INVOKABLE void updateAvatar();
|
||||||
Q_INVOKABLE void openEditModal();
|
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 changeAccessRules(int index);
|
||||||
Q_INVOKABLE void changeNotifications(int currentIndex);
|
Q_INVOKABLE void changeNotifications(int currentIndex);
|
||||||
Q_INVOKABLE bool eventHidden(QString event) const;
|
Q_INVOKABLE bool eventHidden(QString event) const;
|
||||||
|
|
Loading…
Reference in a new issue