Fix unread counter in General topic.

This commit is contained in:
John Preston 2023-10-24 12:51:35 +04:00
parent 9c23de7f1a
commit 91ab82c9da
2 changed files with 16 additions and 14 deletions

View File

@ -282,9 +282,11 @@ Data::Draft *History::createCloudDraft(
} else {
auto existing = cloudDraft(topicRootId);
if (!existing) {
auto reply = fromDraft->reply;
reply.topicRootId = topicRootId;
setCloudDraft(std::make_unique<Data::Draft>(
fromDraft->textWithTags,
fromDraft->reply,
reply,
fromDraft->cursor,
fromDraft->webpage));
existing = cloudDraft(topicRootId);

View File

@ -1845,8 +1845,10 @@ void HistoryItem::destroyHistoryEntry() {
topic->unreadReactions().erase(id);
}
}
if (const auto reply = Get<HistoryMessageReply>()) {
changeReplyToTopCounter(reply, -1);
if (isRegular() && _history->peer->isMegagroup()) {
if (const auto reply = Get<HistoryMessageReply>()) {
changeReplyToTopCounter(reply, -1);
}
}
}
@ -1905,21 +1907,19 @@ void HistoryItem::removeFromSharedMediaIndex() {
}
void HistoryItem::incrementReplyToTopCounter() {
if (const auto reply = Get<HistoryMessageReply>()) {
changeReplyToTopCounter(reply, 1);
if (isRegular() && _history->peer->isMegagroup()) {
_history->session().changes().messageUpdated(
this,
Data::MessageUpdate::Flag::ReplyToTopAdded);
if (const auto reply = Get<HistoryMessageReply>()) {
changeReplyToTopCounter(reply, 1);
}
}
}
void HistoryItem::changeReplyToTopCounter(
not_null<HistoryMessageReply*> reply,
int delta) {
if (!isRegular() || !_history->peer->isMegagroup()) {
return;
} else if (delta > 0) {
_history->session().changes().messageUpdated(
this,
Data::MessageUpdate::Flag::ReplyToTopAdded);
}
const auto topId = reply->topMessageId();
if (!topId) {
return;
@ -1975,7 +1975,7 @@ void HistoryItem::setRealId(MsgId newId) {
if (reply->link()) {
reply->setLinkFrom(this);
}
changeReplyToTopCounter(reply, 1);
incrementReplyToTopCounter();
}
}
@ -2688,7 +2688,7 @@ void HistoryItem::setReplyFields(
&& !IsServerMsgId(reply->topMessageId());
reply->updateFields(this, replyTo, replyToTop, isForumPost);
if (increment) {
changeReplyToTopCounter(reply, 1);
incrementReplyToTopCounter();
}
}
if (const auto topic = this->topic()) {