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) { ForumTopic *Forum::topicFor(MsgId rootId) {
if (rootId != ForumTopic::kGeneralId) { const auto i = _topics.find(rootId);
if (const auto i = _topics.find(rootId); i != end(_topics)) { return (i != end(_topics)) ? i->second.get() : nullptr;
return i->second.get();
}
} else {
// #TODO lang-forum
applyTopicAdded(rootId, "General! Created.", kGeneralColorId, 0);
return _topics.find(rootId)->second.get();
}
return nullptr;
} }
rpl::producer<> Forum::chatsListChanges() const { rpl::producer<> Forum::chatsListChanges() const {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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