From 152b49c65c5edd30942f44d9300437c6a80a5511 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 6 Jul 2020 14:26:00 +0400 Subject: [PATCH] Reset notify settings on unarchive. --- Telegram/SourceFiles/data/data_session.cpp | 13 +++++++++++++ Telegram/SourceFiles/data/data_session.h | 1 + .../history/view/history_view_contact_status.cpp | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 5e9f9a20c3..2b3b9d653c 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -3593,6 +3593,19 @@ void Session::updateNotifySettings( } } +void Session::resetNotifySettingsToDefault(not_null peer) { + const auto empty = MTP_peerNotifySettings( + MTP_flags(0), + MTPBool(), + MTPBool(), + MTPint(), + MTPstring()); + if (peer->notifyChange(empty)) { + updateNotifySettingsLocal(peer); + _session->api().updateNotifySettingsDelayed(peer); + } +} + bool Session::notifyIsMuted( not_null peer, crl::time *changesIn) const { diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index cb91257bb7..e66a83c425 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -596,6 +596,7 @@ public: not_null peer, std::optional muteForSeconds, std::optional silentPosts = std::nullopt); + void resetNotifySettingsToDefault(not_null peer); bool notifyIsMuted( not_null peer, crl::time *changesIn = nullptr) const; diff --git a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp index 356a91b706..338980b331 100644 --- a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp +++ b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp @@ -367,7 +367,7 @@ void ContactStatus::setupUnarchiveHandler(not_null peer) { _bar.entity()->unarchiveClicks( ) | rpl::start_with_next([=] { Window::ToggleHistoryArchived(peer->owner().history(peer), false); - peer->owner().updateNotifySettings(peer, 0); + peer->owner().resetNotifySettingsToDefault(peer); if (const auto settings = peer->settings()) { using Flag = MTPDpeerSettings::Flag; const auto flags = Flag::f_autoarchived