mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Update topic mute state on history mute changes.
This commit is contained in:
parent
d92580b8fc
commit
b68ffcd75d
6 changed files with 36 additions and 2 deletions
Telegram/SourceFiles
data
history
info/profile
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_histories.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_forum_topic.h"
|
||||
#include "data/notify/data_notify_settings.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_unread_things.h"
|
||||
|
@ -285,6 +286,12 @@ void Forum::clearAllUnreadReactions() {
|
|||
}
|
||||
}
|
||||
|
||||
void Forum::enumerateTopics(Fn<void(not_null<ForumTopic*>)> action) const {
|
||||
for (const auto &[rootId, topic] : _topics) {
|
||||
action(topic.get());
|
||||
}
|
||||
}
|
||||
|
||||
ForumTopic *Forum::topicFor(MsgId rootId) {
|
||||
if (!rootId) {
|
||||
return nullptr;
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
|
||||
void clearAllUnreadMentions();
|
||||
void clearAllUnreadReactions();
|
||||
void enumerateTopics(Fn<void(not_null<ForumTopic*>)> action) const;
|
||||
|
||||
private:
|
||||
struct TopicRequest {
|
||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_document.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_forum.h"
|
||||
#include "data/data_forum_topic.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
|
@ -221,6 +222,14 @@ void NotifySettings::resetToDefault(not_null<PeerData*> peer) {
|
|||
}
|
||||
}
|
||||
|
||||
void NotifySettings::forumParentMuteUpdated(not_null<Data::Forum*> forum) {
|
||||
forum->enumerateTopics([&](not_null<Data::ForumTopic*> topic) {
|
||||
if (!topic->notify().settingsUnknown()) {
|
||||
updateLocal(topic);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
auto NotifySettings::defaultValue(DefaultNotify type)
|
||||
-> DefaultValue & {
|
||||
const auto index = static_cast<int>(type);
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Data {
|
|||
class DocumentMedia;
|
||||
class Session;
|
||||
class Thread;
|
||||
class Forum;
|
||||
class ForumTopic;
|
||||
|
||||
enum class DefaultNotify {
|
||||
|
@ -65,6 +66,8 @@ public:
|
|||
std::optional<NotifySound> sound = std::nullopt);
|
||||
void resetToDefault(not_null<PeerData*> peer);
|
||||
|
||||
void forumParentMuteUpdated(not_null<Data::Forum*> forum);
|
||||
|
||||
void cacheSound(DocumentId id);
|
||||
void cacheSound(not_null<DocumentData*> document);
|
||||
[[nodiscard]] std::shared_ptr<DocumentMedia> lookupRingtone(
|
||||
|
|
|
@ -1764,6 +1764,9 @@ void History::setMuted(bool muted) {
|
|||
const auto notify = (unreadCountForBadge() > 0);
|
||||
const auto notifier = unreadStateChangeNotifier(notify);
|
||||
Thread::setMuted(muted);
|
||||
if (const auto forum = peer->forum()) {
|
||||
owner().notifySettings().forumParentMuteUpdated(forum);
|
||||
}
|
||||
}
|
||||
|
||||
void History::getNextFirstUnreadMessage() {
|
||||
|
|
|
@ -452,8 +452,19 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupMuteToggle() {
|
|||
if (button == Qt::RightButton) {
|
||||
return true;
|
||||
}
|
||||
if (notifySettings->isMuted(peer)) {
|
||||
notifySettings->update(peer, { .unmute = true });
|
||||
const auto topic = topicRootId
|
||||
? peer->forumTopicFor(topicRootId)
|
||||
: nullptr;
|
||||
Assert(!topicRootId || topic != nullptr);
|
||||
const auto is = topic
|
||||
? notifySettings->isMuted(topic)
|
||||
: notifySettings->isMuted(peer);
|
||||
if (is) {
|
||||
if (topic) {
|
||||
notifySettings->update(topic, { .unmute = true });
|
||||
} else {
|
||||
notifySettings->update(peer, { .unmute = true });
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue