mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 22:46:10 +00:00
Support unread state in sublists.
This commit is contained in:
@@ -341,6 +341,19 @@ void Session::subscribeForTopicRepliesLists() {
|
||||
}
|
||||
}, _lifetime);
|
||||
|
||||
sublistReadTillUpdates(
|
||||
) | rpl::start_with_next([=](const SublistReadTillUpdate &update) {
|
||||
if (const auto parentChat = channelLoaded(update.parentChatId)) {
|
||||
if (const auto monoforum = parentChat->monoforum()) {
|
||||
const auto sublistPeerId = update.sublistPeerId;
|
||||
const auto peer = monoforum->owner().peer(sublistPeerId);
|
||||
if (const auto sublist = monoforum->sublistLoaded(peer)) {
|
||||
sublist->apply(update);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, _lifetime);
|
||||
|
||||
session().changes().messageUpdates(
|
||||
MessageUpdate::Flag::NewAdded
|
||||
| MessageUpdate::Flag::NewMaybeAdded
|
||||
@@ -349,6 +362,11 @@ void Session::subscribeForTopicRepliesLists() {
|
||||
) | rpl::start_with_next([=](const MessageUpdate &update) {
|
||||
if (const auto topic = update.item->topic()) {
|
||||
topic->replies()->apply(update);
|
||||
} else if (update.flags == MessageUpdate::Flag::ReplyToTopAdded) {
|
||||
// Not interested in this one for sublist.
|
||||
return;
|
||||
} else if (const auto sublist = update.item->savedSublist()) {
|
||||
sublist->apply(update);
|
||||
}
|
||||
}, _lifetime);
|
||||
|
||||
@@ -2914,6 +2932,15 @@ auto Session::repliesReadTillUpdates() const
|
||||
return _repliesReadTillUpdates.events();
|
||||
}
|
||||
|
||||
void Session::updateSublistReadTill(SublistReadTillUpdate update) {
|
||||
_sublistReadTillUpdates.fire(std::move(update));
|
||||
}
|
||||
|
||||
auto Session::sublistReadTillUpdates() const
|
||||
-> rpl::producer<SublistReadTillUpdate> {
|
||||
return _sublistReadTillUpdates.events();
|
||||
}
|
||||
|
||||
int Session::computeUnreadBadge(const Dialogs::UnreadState &state) const {
|
||||
const auto all = Core::App().settings().includeMutedCounter();
|
||||
return std::max(state.marks - (all ? 0 : state.marksMuted), 0)
|
||||
|
Reference in New Issue
Block a user