2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +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

@@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_send_action.h"
#include "data/data_folder.h"
#include "data/data_forum.h"
#include "data/data_forum_topic.h"
#include "data/data_photo.h"
#include "data/data_channel.h"
#include "data/data_chat.h"
@@ -159,6 +160,15 @@ void History::itemRemoved(not_null<HistoryItem*> item) {
if (IsClientMsgId(item->id)) {
unregisterClientSideMessage(item);
}
if (const auto forum = peer->forum()) {
if (const auto topic = forum->topicFor(item)) {
if (topic->rootId() == item->id) {
forum->applyTopicRemoved(item->id);
} else {
topic->applyItemRemoved(item->id);
}
}
}
if (const auto chat = peer->asChat()) {
if (const auto to = chat->getMigrateToChannel()) {
if (const auto history = owner().historyLoaded(to)) {
@@ -1124,9 +1134,13 @@ void History::newItemAdded(not_null<HistoryItem*> item) {
if (!folderKnown()) {
owner().histories().requestDialogEntry(this);
}
if (item->isTopicStart() && peer->isForum()) {
if (peer->isForum()) {
if (const auto forum = peer->asChannel()->forum()) {
forum->topicAdded(item);
/*if (item->isTopicStart()) { // #TODO forum isTopicStart legacy?
forum->topicAdded(item);
} else */if (const auto topic = forum->topicFor(item)) {
topic->applyItemAdded(item);
}
}
}
}