2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Create / move forum topics on new messages.

This commit is contained in:
John Preston
2022-09-23 23:21:31 +04:00
parent 388fe6adfb
commit eaf679916a
19 changed files with 155 additions and 58 deletions

View File

@@ -37,13 +37,7 @@ void ForumTopic::applyTopic(const MTPForumTopic &topic) {
Expects(_rootId == topic.data().vid().v);
const auto &data = topic.data();
const auto title = qs(data.vtitle());
if (_title != title) {
_title = title;
++_titleVersion;
indexTitleParts();
updateChatListEntry();
}
applyTitle(qs(data.vtitle()));
const auto pinned = _list->pinned();
if (data.is_pinned()) {
@@ -216,7 +210,7 @@ TimeId ForumTopic::adjustedChatListTimeId() const {
}
int ForumTopic::fixedOnTopIndex() const {
return kArchiveFixOnTopIndex;
return 0;
}
bool ForumTopic::shouldBeInChatList() const {
@@ -241,6 +235,38 @@ bool ForumTopic::lastServerMessageKnown() const {
return _lastServerMessage.has_value();
}
void ForumTopic::applyTitle(const QString &title) {
if (_title == title) {
return;
}
_title = title;
++_titleVersion;
indexTitleParts();
updateChatListEntry();
}
void ForumTopic::applyItemAdded(not_null<HistoryItem*> item) {
setLastMessage(item);
}
void ForumTopic::applyItemRemoved(MsgId id) {
if (const auto lastItem = lastMessage()) {
if (lastItem->id == id) {
_lastMessage = std::nullopt;
}
}
if (const auto lastServerItem = lastServerMessage()) {
if (lastServerItem->id == id) {
_lastServerMessage = std::nullopt;
}
}
if (const auto chatListItem = _chatListMessage.value_or(nullptr)) {
if (chatListItem->id == id) {
_chatListMessage = std::nullopt;
}
}
}
int ForumTopic::unreadCount() const {
return _unreadCount ? *_unreadCount : 0;
}