mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Improve topic creation, fix glitches.
This commit is contained in:
parent
fd2edb51e9
commit
ce17904dcc
6 changed files with 21 additions and 13 deletions
|
@ -337,6 +337,7 @@ void EditForumTopicBox(
|
|||
const auto topic = (!creating && forum->peer->forum())
|
||||
? forum->peer->forum()->topicFor(rootId)
|
||||
: nullptr;
|
||||
const auto created = topic && !topic->creating();
|
||||
box->setTitle(creating
|
||||
? tr::lng_forum_topic_new()
|
||||
: tr::lng_forum_topic_edit());
|
||||
|
@ -394,7 +395,7 @@ void EditForumTopicBox(
|
|||
) | rpl::start_with_next([=](DocumentId iconId) {
|
||||
icon->setAttribute(
|
||||
Qt::WA_TransparentForMouseEvents,
|
||||
!creating || (iconId != 0));
|
||||
created || (iconId != 0));
|
||||
}, box->lifetime());
|
||||
|
||||
icon->setClickedCallback([=] {
|
||||
|
|
|
@ -388,7 +388,9 @@ void ForumTopic::setLastServerMessage(HistoryItem *item) {
|
|||
if (_lastMessage
|
||||
&& *_lastMessage
|
||||
&& !(*_lastMessage)->isRegular()
|
||||
&& (!item || (*_lastMessage)->date() > item->date())) {
|
||||
&& (!item
|
||||
|| (*_lastMessage)->date() > item->date()
|
||||
|| (*_lastMessage)->isSending())) {
|
||||
return;
|
||||
}
|
||||
setLastMessage(item);
|
||||
|
@ -566,7 +568,11 @@ void ForumTopic::applyColorId(int32 colorId) {
|
|||
}
|
||||
|
||||
void ForumTopic::applyItemAdded(not_null<HistoryItem*> item) {
|
||||
setLastMessage(item);
|
||||
if (item->isRegular()) {
|
||||
setLastServerMessage(item);
|
||||
} else {
|
||||
setLastMessage(item);
|
||||
}
|
||||
}
|
||||
|
||||
void ForumTopic::maybeSetLastMessage(not_null<HistoryItem*> item) {
|
||||
|
|
|
@ -946,11 +946,11 @@ void Histories::checkTopicCreated(FullMsgId rootId, MsgId realRoot) {
|
|||
|
||||
_createdTopicIds.emplace(rootId, realRoot);
|
||||
|
||||
if (const auto forum = _owner->peer(rootId.peer)->forum()) {
|
||||
const auto history = _owner->history(rootId.peer);
|
||||
if (const auto forum = history->peer->forum()) {
|
||||
forum->created(rootId.msg, realRoot);
|
||||
}
|
||||
|
||||
const auto history = _owner->history(rootId.peer);
|
||||
for (auto &entry : scheduled) {
|
||||
_creatingTopicRequests.erase(entry.requestId);
|
||||
sendPreparedMessage(
|
||||
|
@ -962,6 +962,7 @@ void Histories::checkTopicCreated(FullMsgId rootId, MsgId realRoot) {
|
|||
std::move(entry.done),
|
||||
std::move(entry.fail));
|
||||
}
|
||||
const auto topic = history->peer->forumTopicFor(realRoot);
|
||||
for (const auto &item : history->clientSideMessages()) {
|
||||
const auto replace = [&](MsgId nowId) {
|
||||
return (nowId == rootId.msg) ? realRoot : nowId;
|
||||
|
|
|
@ -131,7 +131,7 @@ rpl::producer<MessagesSlice> RepliesList::source(
|
|||
|
||||
_history->session().changes().historyUpdates(
|
||||
_history,
|
||||
Data::HistoryUpdate::Flag::ClientSideMessages
|
||||
HistoryUpdate::Flag::ClientSideMessages
|
||||
) | rpl::start_with_next(pushDelayed, lifetime);
|
||||
|
||||
_history->session().changes().messageUpdates(
|
||||
|
@ -744,7 +744,7 @@ void RepliesList::setOutboxReadTill(MsgId readTillId) {
|
|||
_outboxReadTillId = newReadTillId;
|
||||
_history->session().changes().historyUpdated(
|
||||
_history,
|
||||
Data::HistoryUpdate::Flag::OutboxRead);
|
||||
HistoryUpdate::Flag::OutboxRead);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -792,7 +792,7 @@ std::optional<int> RepliesList::computeUnreadCountLocally(
|
|||
|
||||
const auto wasUnreadCountAfter = _unreadCount.current();
|
||||
const auto readTillId = std::max(afterId, _rootId);
|
||||
const auto wasReadTillId = std::max(_inboxReadTillId, _rootId);
|
||||
const auto wasReadTillId = _inboxReadTillId;
|
||||
const auto backLoaded = (_skippedBefore == 0);
|
||||
const auto frontLoaded = (_skippedAfter == 0);
|
||||
const auto fullLoaded = backLoaded && frontLoaded;
|
||||
|
@ -838,7 +838,7 @@ std::optional<int> RepliesList::computeUnreadCountLocally(
|
|||
end(_list),
|
||||
wasReadTillId,
|
||||
std::greater<>());
|
||||
return std::max(*wasUnreadCountAfter - countIncoming(from, till), 0);
|
||||
return std::max(*wasUnreadCountAfter - (till - from), 0);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
|
@ -1079,7 +1079,8 @@ bool HistoryItem::computeDropForwardedInfo() const {
|
|||
}
|
||||
|
||||
bool HistoryItem::inThread(MsgId rootId) const {
|
||||
return (replyToTop() == rootId);
|
||||
return (replyToTop() == rootId)
|
||||
|| (topicRootId() == rootId);
|
||||
}
|
||||
|
||||
not_null<PeerData*> HistoryItem::author() const {
|
||||
|
|
|
@ -661,7 +661,7 @@ void HistoryMessage::createComponentsHelper(
|
|||
const auto forum = history()->peer->forum();
|
||||
config.replyIsTopicPost = LookupReplyIsTopicPost(to)
|
||||
|| (to && to->Has<HistoryServiceTopicInfo>())
|
||||
|| (forum && forum->creating(replyToTop));
|
||||
|| (forum && forum->creating(config.replyToTop));
|
||||
}
|
||||
config.markup = std::move(markup);
|
||||
if (flags & MessageFlag::HasPostAuthor) config.author = postAuthor;
|
||||
|
@ -1813,8 +1813,7 @@ void HistoryMessage::changeReplyToTopCounter(
|
|||
int delta) {
|
||||
if (!isRegular() || !_history->peer->isMegagroup()) {
|
||||
return;
|
||||
}
|
||||
if (!out() && delta > 0) {
|
||||
} else if (delta > 0) {
|
||||
_history->session().changes().messageUpdated(
|
||||
this,
|
||||
Data::MessageUpdate::Flag::ReplyToTopAdded);
|
||||
|
|
Loading…
Add table
Reference in a new issue