From 9d00f110f0725c7f0cb58f12e729fbb4008413a8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 19 Jul 2026 00:44:19 +0400 Subject: [PATCH] Show plain topics list for forum opened in community. --- .../dialogs/dialogs_inner_widget.cpp | 41 +++++++++++-------- .../dialogs/dialogs_inner_widget.h | 1 + .../SourceFiles/dialogs/dialogs_widget.cpp | 1 + 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index fa370dab63..59ad1a4008 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -616,7 +616,7 @@ bool InnerWidget::updateEntryHeight(not_null entry) { top += result.row->height(); } } - if (_openedCommunity) { + if (communityModeShown()) { if (const auto history = entry->asHistory()) { const auto recount = [&](CommunityRowsView &view) { if (view.contains(history)) { @@ -637,7 +637,7 @@ void InnerWidget::setNarrowRatio(float64 narrowRatio) { _geometryInited = true; _narrowRatio = narrowRatio; auto changed = _shownList->updateHeights(_narrowRatio); - if (_openedCommunity) { + if (communityModeShown()) { const auto recount = [&](CommunityRowsView &view) { const auto was = view.height(); view.recountHeights(_narrowRatio); @@ -709,7 +709,7 @@ int InnerWidget::dialogsOffset() const { return collapsedRowsOffset() + (_collapsedRows.size() * st::dialogsImportantBarHeight) - skipTopHeight() - + ((_openedCommunity && !_shownList->empty()) + + ((communityModeShown() && !_shownList->empty()) ? st::searchedBarHeight : 0); } @@ -832,6 +832,10 @@ int InnerWidget::communityRowAbsoluteTop(int index) const { + _communityViewable.rowTop(index); } +bool InnerWidget::communityModeShown() const { + return _openedCommunity && !_openedForum; +} + void InnerWidget::changeOpenedFolder(Data::Folder *folder) { Expects(!folder || !_savedSublists); @@ -870,6 +874,9 @@ void InnerWidget::changeOpenedForum(Data::Forum *forum) { _openedForum = forum; _st = forum ? &st::forumTopicRow : &st::defaultDialogRow; refreshShownList(); + if (!forum && _openedCommunity) { + rebuildCommunitySections(); + } _openedForumLifetime.destroy(); if (forum) { @@ -895,7 +902,7 @@ void InnerWidget::rebuildCommunitySections() { _communityViewable.clear(); _communitySelected = -1; setCommunityPressed(-1); - if (!_openedCommunity) { + if (!communityModeShown()) { return; } const auto owner = &session().data(); @@ -1012,14 +1019,14 @@ void InnerWidget::paintEvent(QPaintEvent *e) { .topicJumpCache = _topicJumpCache.get(), .folder = _openedFolder, .forum = _openedForum, - .community = _openedCommunity, + .community = communityModeShown() ? _openedCommunity : nullptr, .currentBg = currentBg(), .filter = _filterId, .now = ms, .width = fullWidth, .paused = videoPaused, .narrow = (fullWidth < st::columnMinimalWidthLeft / 2), - .insideCommunity = (_openedCommunity != nullptr), + .insideCommunity = communityModeShown(), }; const auto fillGuard = gsl::finally([&] { // We translate painter down, but it'll be cropped below rect. @@ -1216,14 +1223,14 @@ void InnerWidget::paintEvent(QPaintEvent *e) { } }; if (_state == WidgetState::Default) { - if (_openedCommunity) { + if (communityModeShown()) { p.save(); } const auto collapsedSkip = collapsedRowsOffset(); p.translate(0, collapsedSkip); paintCollapsedRows(p, r.translated(0, -collapsedSkip)); - if (_openedCommunity && !_shownList->empty()) { + if (communityModeShown() && !_shownList->empty()) { p.translate(0, st::searchedBarHeight); } @@ -1309,7 +1316,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) { } else { p.fillRect(dialogsClip, currentBg()); } - if (_openedCommunity) { + if (communityModeShown()) { p.restore(); const auto paintBar = [&](const QString &text) { p.fillRect( @@ -2213,7 +2220,7 @@ void InnerWidget::selectByMouse(QPoint globalPosition) { const auto selectedRightButton = selected && lookupIsInBotAppButton(selected, QPoint(local.x(), mappedY)); auto communitySelected = -1; - if (_openedCommunity && !selected && collapsedSelected < 0) { + if (communityModeShown() && !selected && collapsedSelected < 0) { const auto pick = [&]( int sectionTop, int flatBase, @@ -3258,7 +3265,7 @@ void InnerWidget::handleChatListEntryRefreshes() { return (topic->forum() == _openedForum); } else if (const auto sublist = event.key.sublist()) { return sublist->parent() == _savedSublists; - } else if (_openedCommunity) { + } else if (communityModeShown()) { const auto history = event.key.history(); return history && (history->communityListInfo() == _openedCommunity); @@ -3286,7 +3293,7 @@ void InnerWidget::handleChatListEntryRefreshes() { ? (key.topic()->forum() == _openedForum) : key.sublist() ? (key.sublist()->parent() == _savedSublists) - : _openedCommunity + : communityModeShown() ? (entry->asHistory() && entry->asHistory()->communityListInfo() == _openedCommunity) @@ -3324,7 +3331,7 @@ void InnerWidget::handleChatListEntryRefreshes() { } _updated.fire({}); } - if (_openedCommunity) { + if (communityModeShown()) { rebuildCommunitySections(); } refresh(); @@ -4769,7 +4776,7 @@ void InnerWidget::refresh(bool toTop) { } auto h = 0; if (_state == WidgetState::Default) { - if (_openedCommunity) { + if (communityModeShown()) { const auto requestableShown = _communityRequestableList && (_communityRequestableCount > 0); if (_shownList->empty() @@ -5009,7 +5016,7 @@ void InnerWidget::updateCommunityRequestableGeometry() { if (!_communityRequestableList) { return; } - const auto shown = _openedCommunity + const auto shown = communityModeShown() && (_state == WidgetState::Default) && (_communityRequestableCount > 0); _communityRequestableList->setVisible(shown); @@ -5063,7 +5070,7 @@ bool InnerWidget::archiveSearchActive() const { } bool InnerWidget::communitySearchActive() const { - return (_openedCommunity || _searchState.community) + return (communityModeShown() || _searchState.community) && ((_searchState.tab == ChatSearchTab::ThisCommunity) || !QStringView(_searchState.query).trimmed().isEmpty()); } @@ -5136,7 +5143,7 @@ void InnerWidget::updateSearchIn() { : nullptr; const auto communityChannel = _searchState.community ? _searchState.community - : _openedCommunity + : communityModeShown() ? _openedCommunity->channel().get() : nullptr; const auto communityIcon = (communityChannel && !_searchState.inChat) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h index 1b974699d8..dc5b2f7f83 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h @@ -489,6 +489,7 @@ private: [[nodiscard]] int communityRowCount() const; [[nodiscard]] Row *communityRowAt(int index) const; [[nodiscard]] int communityRowAbsoluteTop(int index) const; + [[nodiscard]] bool communityModeShown() const; void paintCollapsedRows( Painter &p, diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index bc168fa4bd..0847494755 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -1301,6 +1301,7 @@ void Widget::updateTopBarSuggestions() { bool Widget::communityOverlaysShown() const { return _openedCommunity + && !_openedForum && (_inner->state() == WidgetState::Default); }