2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-04 00:25:17 +00:00

Track unread mentions / reactions in topics.

This commit is contained in:
John Preston
2022-10-07 17:56:07 +04:00
parent 9348039313
commit 2c0b5b3210
22 changed files with 448 additions and 192 deletions

View File

@@ -18,8 +18,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "main/main_session_settings.h"
#include "ui/text/text_options.h"
#include "history/history_item.h"
#include "history/history.h"
#include "history/history_item.h"
#include "history/history_unread_things.h"
#include "styles/style_dialogs.h" // st::dialogsTextWidthMin
namespace Dialogs {
@@ -49,6 +50,8 @@ Entry::Entry(not_null<Data::Session*> owner, Type type)
, _type(type) {
}
Entry::~Entry() = default;
Data::Session &Entry::owner() const {
return *_owner;
}
@@ -102,19 +105,30 @@ void Entry::cachePinnedIndex(FilterId filterId, int index) {
}
void Entry::cacheTopPromoted(bool promoted) {
if (_isTopPromoted == promoted) {
if (isTopPromoted() == promoted) {
return;
} else if (promoted) {
_flags |= Flag::IsTopPromoted;
} else {
_flags &= ~Flag::IsTopPromoted;
}
_isTopPromoted = promoted;
updateChatListSortPosition();
updateChatListEntry();
if (!_isTopPromoted) {
if (!isTopPromoted()) {
updateChatListExistence();
}
}
bool Entry::isTopPromoted() const {
return _isTopPromoted;
return (_flags & Flag::IsTopPromoted);
}
const base::flat_set<MsgId> &Entry::unreadMentionsIds() const {
if (!_unreadThings) {
static const auto Result = base::flat_set<MsgId>();
return Result;
}
return _unreadThings->mentions.ids();
}
bool Entry::needUpdateInChatList() const {
@@ -198,6 +212,42 @@ TimeId Entry::adjustedChatListTimeId() const {
return chatListTimeId();
}
void Entry::setUnreadThingsKnown() {
_flags |= Flag::UnreadThingsKnown;
}
HistoryUnreadThings::Proxy Entry::unreadMentions() {
return {
this,
_unreadThings,
HistoryUnreadThings::Type::Mentions,
!!(_flags & Flag::UnreadThingsKnown),
};
}
HistoryUnreadThings::ConstProxy Entry::unreadMentions() const {
return {
_unreadThings ? &_unreadThings->mentions : nullptr,
!!(_flags & Flag::UnreadThingsKnown),
};
}
HistoryUnreadThings::Proxy Entry::unreadReactions() {
return {
this,
_unreadThings,
HistoryUnreadThings::Type::Reactions,
!!(_flags & Flag::UnreadThingsKnown),
};
}
HistoryUnreadThings::ConstProxy Entry::unreadReactions() const {
return {
_unreadThings ? &_unreadThings->reactions : nullptr,
!!(_flags & Flag::UnreadThingsKnown),
};
}
void Entry::changedChatListPinHook() {
}