From 866c5e9b7b3e6452580ff2120b9c31c052e33341 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 6 Jun 2018 22:56:35 +0300 Subject: [PATCH] Request common notify settings when needed. If user / group has default notify settings we need common user or common group notify settings to display the badge properly. --- Telegram/SourceFiles/apiwrap.h | 8 ++++---- Telegram/SourceFiles/base/flat_map.h | 6 ++++++ Telegram/SourceFiles/base/flat_set.h | 6 ++++++ Telegram/SourceFiles/data/data_session.cpp | 7 ++----- Telegram/SourceFiles/history/history.cpp | 4 ++++ Telegram/SourceFiles/window/window_controller.cpp | 4 ++-- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index 8bcf553802..dbebeba7c1 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -487,10 +487,10 @@ private: QMap > _stickerSetRequests; QMap _channelAmInRequests; - std::map, mtpRequestId> _blockRequests; - std::map, mtpRequestId> _exportInviteRequests; - std::map _notifySettingRequests; - std::map, mtpRequestId> _draftsSaveRequestIds; + base::flat_map, mtpRequestId> _blockRequests; + base::flat_map, mtpRequestId> _exportInviteRequests; + base::flat_map _notifySettingRequests; + base::flat_map, mtpRequestId> _draftsSaveRequestIds; base::Timer _draftsSaveTimer; base::flat_set _stickerSetDisenableRequests; diff --git a/Telegram/SourceFiles/base/flat_map.h b/Telegram/SourceFiles/base/flat_map.h index 8bed4a422c..75770e4f97 100644 --- a/Telegram/SourceFiles/base/flat_map.h +++ b/Telegram/SourceFiles/base/flat_map.h @@ -13,6 +13,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace base { +using std::begin; +using std::end; + template < typename Key, typename Type, @@ -424,6 +427,9 @@ public: iterator erase(const_iterator from, const_iterator till) { return impl().erase(from._impl, till._impl); } + int erase(const Key &key) { + return removeAll(key); + } iterator findFirst(const Key &key) { if (empty() diff --git a/Telegram/SourceFiles/base/flat_set.h b/Telegram/SourceFiles/base/flat_set.h index 1dbbbd3b02..368bd104d3 100644 --- a/Telegram/SourceFiles/base/flat_set.h +++ b/Telegram/SourceFiles/base/flat_set.h @@ -12,6 +12,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace base { +using std::begin; +using std::end; + template > class flat_set; @@ -304,6 +307,9 @@ public: iterator erase(const_iterator from, const_iterator till) { return impl().erase(from._impl, till._impl); } + int erase(const Type &value) { + return removeAll(value); + } iterator findFirst(const Type &value) { if (empty() diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index d3705c9e4b..aecd057525 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -1692,12 +1692,9 @@ void Session::applyNotifySetting( App::enumerateChatsChannels([&](not_null peer) { if (!peer->notifySettingsUnknown() && ((!peer->notifyMuteUntil() - && _defaultUserNotifySettings.muteUntil()) + && _defaultChatNotifySettings.muteUntil()) || (!peer->notifySilentPosts() - && _defaultUserNotifySettings.silentPosts()))) { - if (!peer->notifyMuteUntil()) { - int a = 0; - } + && _defaultChatNotifySettings.silentPosts()))) { updateNotifySettingsLocal(peer); } }); diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 8a52b63c68..220c0e7d5f 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -2197,6 +2197,10 @@ void History::applyDialog(const MTPDdialog &data) { Auth().data().applyNotifySetting( MTP_notifyPeer(data.vpeer), data.vnotify_settings); + + // Request default notification settings for this type of chat. + Auth().data().requestNotifySettings(peer); + if (data.has_draft() && data.vdraft.type() == mtpc_draftMessage) { Data::applyPeerCloudDraft(peer->id, data.vdraft.c_draftMessage()); } diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index 4e9e487529..44ef88b4cf 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -476,9 +476,9 @@ void Navigation::showPeerInfo( void Controller::showSection( SectionMemento &&memento, const SectionShow ¶ms) { - if (App::wnd()->showSectionInExistingLayer( + if (!params.thirdColumn && App::wnd()->showSectionInExistingLayer( &memento, - params) && !params.thirdColumn) { + params)) { return; } App::main()->showSection(std::move(memento), params);