mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_histories.h"
|
#include "data/data_histories.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_forum_topic.h"
|
#include "data/data_forum_topic.h"
|
||||||
|
#include "data/notify/data_notify_settings.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/history_unread_things.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) {
|
ForumTopic *Forum::topicFor(MsgId rootId) {
|
||||||
if (!rootId) {
|
if (!rootId) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -65,6 +65,7 @@ public:
|
||||||
|
|
||||||
void clearAllUnreadMentions();
|
void clearAllUnreadMentions();
|
||||||
void clearAllUnreadReactions();
|
void clearAllUnreadReactions();
|
||||||
|
void enumerateTopics(Fn<void(not_null<ForumTopic*>)> action) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct TopicRequest {
|
struct TopicRequest {
|
||||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
|
#include "data/data_forum.h"
|
||||||
#include "data/data_forum_topic.h"
|
#include "data/data_forum_topic.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.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)
|
auto NotifySettings::defaultValue(DefaultNotify type)
|
||||||
-> DefaultValue & {
|
-> DefaultValue & {
|
||||||
const auto index = static_cast<int>(type);
|
const auto index = static_cast<int>(type);
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace Data {
|
||||||
class DocumentMedia;
|
class DocumentMedia;
|
||||||
class Session;
|
class Session;
|
||||||
class Thread;
|
class Thread;
|
||||||
|
class Forum;
|
||||||
class ForumTopic;
|
class ForumTopic;
|
||||||
|
|
||||||
enum class DefaultNotify {
|
enum class DefaultNotify {
|
||||||
|
@ -65,6 +66,8 @@ public:
|
||||||
std::optional<NotifySound> sound = std::nullopt);
|
std::optional<NotifySound> sound = std::nullopt);
|
||||||
void resetToDefault(not_null<PeerData*> peer);
|
void resetToDefault(not_null<PeerData*> peer);
|
||||||
|
|
||||||
|
void forumParentMuteUpdated(not_null<Data::Forum*> forum);
|
||||||
|
|
||||||
void cacheSound(DocumentId id);
|
void cacheSound(DocumentId id);
|
||||||
void cacheSound(not_null<DocumentData*> document);
|
void cacheSound(not_null<DocumentData*> document);
|
||||||
[[nodiscard]] std::shared_ptr<DocumentMedia> lookupRingtone(
|
[[nodiscard]] std::shared_ptr<DocumentMedia> lookupRingtone(
|
||||||
|
|
|
@ -1764,6 +1764,9 @@ void History::setMuted(bool muted) {
|
||||||
const auto notify = (unreadCountForBadge() > 0);
|
const auto notify = (unreadCountForBadge() > 0);
|
||||||
const auto notifier = unreadStateChangeNotifier(notify);
|
const auto notifier = unreadStateChangeNotifier(notify);
|
||||||
Thread::setMuted(muted);
|
Thread::setMuted(muted);
|
||||||
|
if (const auto forum = peer->forum()) {
|
||||||
|
owner().notifySettings().forumParentMuteUpdated(forum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::getNextFirstUnreadMessage() {
|
void History::getNextFirstUnreadMessage() {
|
||||||
|
|
|
@ -452,8 +452,19 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupMuteToggle() {
|
||||||
if (button == Qt::RightButton) {
|
if (button == Qt::RightButton) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (notifySettings->isMuted(peer)) {
|
const auto topic = topicRootId
|
||||||
notifySettings->update(peer, { .unmute = true });
|
? 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;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue