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