Remove General meta-forum-topic.

This commit is contained in:
John Preston 2022-10-13 12:46:30 +04:00
parent 92a4b27e65
commit 9fccdf21cc
8 changed files with 12 additions and 41 deletions

View File

@ -267,16 +267,8 @@ ForumTopic *Forum::topicFor(not_null<const HistoryItem*> item) {
}
ForumTopic *Forum::topicFor(MsgId rootId) {
if (rootId != ForumTopic::kGeneralId) {
if (const auto i = _topics.find(rootId); i != end(_topics)) {
return i->second.get();
}
} else {
// #TODO lang-forum
applyTopicAdded(rootId, "General! Created.", kGeneralColorId, 0);
return _topics.find(rootId)->second.get();
}
return nullptr;
const auto i = _topics.find(rootId);
return (i != end(_topics)) ? i->second.get() : nullptr;
}
rpl::producer<> Forum::chatsListChanges() const {

View File

@ -374,9 +374,6 @@ void ForumTopic::requestChatListMessage() {
}
TimeId ForumTopic::adjustedChatListTimeId() const {
if (isGeneral()) {
return TimeId(1);
}
const auto result = chatListTimeId();
#if 0 // #TODO forum draft
if (const auto draft = cloudDraft()) {
@ -419,10 +416,10 @@ QString ForumTopic::title() const {
}
void ForumTopic::applyTitle(const QString &title) {
if (_title == title || (isGeneral() && !_title.isEmpty())) {
if (_title == title) {
return;
}
_title = isGeneral() ? "General! Topic." : title; // #TODO lang-forum
_title = title;
++_titleVersion;
_defaultIcon = QImage();
indexTitleParts();

View File

@ -44,8 +44,6 @@ class Forum;
class ForumTopic final : public Dialogs::Entry {
public:
static constexpr auto kGeneralId = 1;
ForumTopic(not_null<History*> history, MsgId rootId);
~ForumTopic();
@ -58,9 +56,6 @@ public:
[[nodiscard]] not_null<Forum*> forum() const;
[[nodiscard]] rpl::producer<> destroyed() const;
[[nodiscard]] MsgId rootId() const;
[[nodiscard]] bool isGeneral() const {
return (_rootId == kGeneralId);
}
void setRealRootId(MsgId realId);

View File

@ -228,7 +228,7 @@ void RepliesList::injectRootMessage(not_null<Viewer*> viewer) {
return;
}
const auto root = lookupRoot();
if (!root || root->topicRootId() != Data::ForumTopic::kGeneralId) {
if (!root || root->topicRootId()) {
return;
}
injectRootDivider(root, slice);

View File

@ -1066,10 +1066,7 @@ bool HistoryItem::computeDropForwardedInfo() const {
}
bool HistoryItem::inThread(MsgId rootId) const {
const auto checkId = (rootId == Data::ForumTopic::kGeneralId)
? topicRootId()
: replyToTop();
return (checkId == rootId);
return (replyToTop() == rootId);
}
not_null<PeerData*> HistoryItem::author() const {

View File

@ -216,8 +216,7 @@ MsgId LookupReplyToTop(HistoryItem *replyTo) {
}
bool LookupReplyIsTopicPost(HistoryItem *replyTo) {
return replyTo
&& (replyTo->topicRootId() != Data::ForumTopic::kGeneralId);
return replyTo && (replyTo->topicRootId() != 0);
}
MTPMessageReplyHeader NewMessageReplyHeader(const Api::SendAction &action) {
@ -1490,7 +1489,7 @@ MsgId HistoryMessage::topicRootId() const {
; reply && reply->topicPost) {
return reply->replyToTop();
}
return Data::ForumTopic::kGeneralId;
return 0;
}
void HistoryMessage::setText(const TextWithEntities &textWithEntities) {

View File

@ -1310,10 +1310,10 @@ MsgId HistoryService::topicRootId() const {
if (const auto data = GetDependentData()
; data && data->topicPost && data->topId) {
return data->topId;
} else if (const auto topic = Get<HistoryServiceTopicInfo>()) {
} else if (Has<HistoryServiceTopicInfo>()) {
return id;
}
return Data::ForumTopic::kGeneralId;
return 0;
}
void HistoryService::setReplyFields(

View File

@ -1360,11 +1360,7 @@ void RepliesWidget::refreshTopBarActiveChat() {
MsgId RepliesWidget::replyToId() const {
const auto custom = _composeControls->replyingToMessage().msg;
return custom
? custom
: (_rootId == Data::ForumTopic::kGeneralId)
? MsgId(0)
: _rootId;
return custom ? custom : _rootId;
}
void RepliesWidget::refreshUnreadCountBadge(std::optional<int> count) {
@ -1577,18 +1573,13 @@ bool RepliesWidget::showMessage(
return false;
}
auto originFound = false;
const auto general = (_rootId == Data::ForumTopic::kGeneralId);
const auto originMessage = [&]() -> HistoryItem* {
using OriginMessage = Window::SectionShow::OriginMessage;
if (const auto origin = std::get_if<OriginMessage>(&params.origin)) {
if (const auto returnTo = session().data().message(origin->id)) {
if (returnTo->history() != _history) {
return nullptr;
} else if (general
&& _inner->viewByPosition(returnTo->position())
&& returnTo->replyToId() == messageId) {
return returnTo;
} else if (!general && returnTo->inThread(_rootId)) {
} else if (returnTo->inThread(_rootId)) {
return returnTo;
}
}