Fix opening forums with tabs.

This commit is contained in:
John Preston 2025-05-26 14:01:04 +04:00
parent 1d26482298
commit 0e5419c60b
6 changed files with 30 additions and 11 deletions

View file

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "dialogs/dialogs_search_tags.h"
#include "dialogs/dialogs_quick_action.h"
#include "history/view/history_view_context_menu.h"
#include "history/view/history_view_subsection_tabs.h"
#include "history/history.h"
#include "history/history_item.h"
#include "core/application.h"
@ -1500,6 +1501,12 @@ bool InnerWidget::isRowActive(
const auto key = row->key();
if (entry.key == key) {
return true;
} else if (const auto topic = entry.key.topic()) {
if (const auto history = key.history()) {
return (history->peer == topic->channel())
&& HistoryView::SubsectionTabs::UsedFor(history);
}
return false;
} else if (const auto sublist = entry.key.sublist()) {
if (!sublist->parentChat()) {
// In case we're viewing a Saved Messages sublist,

View file

@ -6466,7 +6466,9 @@ void HistoryWidget::updateControlsGeometry() {
const auto scrollAreaTop = _topBars->y()
+ businessBotTop
+ (_businessBotStatus ? _businessBotStatus->bar().height() : 0);
_topBars->resize(innerWidth, scrollAreaTop - _topBars->y());
_topBars->resize(
innerWidth,
scrollAreaTop - _topBars->y() + st::lineWidth);
if (_scroll->y() != scrollAreaTop) {
_scroll->moveToLeft(tabsLeftSkip, scrollAreaTop);
if (_autocomplete) {

View file

@ -468,6 +468,7 @@ ChatWidget::~ChatWidget() {
}
void ChatWidget::orderWidgets() {
_topBars->raise();
_translateBar->raise();
if (_topicReopenBar) {
_topicReopenBar->bar().raise();
@ -2608,7 +2609,7 @@ void ChatWidget::updateControlsGeometry() {
bottom -= _composeControls->heightCurrent();
}
_topBars->resize(innerWidth, top);
_topBars->resize(innerWidth, top + st::lineWidth);
top += _topBars->y();
const auto scrollHeight = bottom - top;

View file

@ -46,6 +46,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_group_call.h" // GroupCall::input.
#include "data/data_folder.h"
#include "data/data_forum.h"
#include "data/data_saved_messages.h"
#include "data/data_saved_sublist.h"
#include "data/data_session.h"
#include "data/data_stories.h"
@ -55,6 +56,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_changes.h"
#include "data/data_forum_topic.h"
#include "data/data_send_action.h"
#include "dialogs/dialogs_main_list.h"
#include "chat_helpers/emoji_interactions.h"
#include "base/unixtime.h"
#include "support/support_helper.h"
@ -488,14 +490,16 @@ void TopBarWidget::paintTopBar(Painter &p) {
const auto sublist = _activeChat.key.sublist();
const auto topic = _activeChat.key.topic();
const auto history = _activeChat.key.history();
const auto namePeer = history
const auto broadcastForMonoforum = history
? history->peer->monoforumBroadcast()
: nullptr;
const auto namePeer = broadcastForMonoforum
? broadcastForMonoforum
: history
? history->peer.get()
: sublist
? sublist->sublistPeer().get()
: nullptr;
const auto broadcastForMonoforum = history
? history->peer->monoforumBroadcast()
: nullptr;
if (topic && _activeChat.section == Section::Replies) {
p.setPen(st::dialogsNameFg);
topic->chatListNameText().drawElided(
@ -519,12 +523,9 @@ void TopBarWidget::paintTopBar(Painter &p) {
}
} else if (folder
|| (peer && (peer->sharedMediaInfo() || peer->isVerifyCodes()))
|| broadcastForMonoforum
|| (_activeChat.section == Section::Scheduled)
|| (_activeChat.section == Section::Pinned)) {
auto text = broadcastForMonoforum
? broadcastForMonoforum->name() + u" Messages"_q AssertIsDebug()
: (_activeChat.section == Section::Scheduled)
auto text = (_activeChat.section == Section::Scheduled)
? ((peer && peer->isSelf())
? tr::lng_reminder_messages(tr::now)
: tr::lng_scheduled_messages(tr::now))
@ -1690,6 +1691,10 @@ void TopBarWidget::updateOnlineDisplay() {
text = tr::lng_group_status(tr::now);
}
}
} else if (const auto monoforum = peer->monoforum()) {
const auto chats = monoforum->chatsList();
const auto count = chats->fullSize().current();
text = tr::lng_filters_chats_count(tr::now, lt_count, count);
} else if (const auto channel = peer->asChannel()) {
if (channel->isMegagroup()
&& channel->canViewMembers()

View file

@ -232,7 +232,7 @@ TranslateBar::TranslateBar(
: _controller(controller)
, _history(history)
, _wrap(parent, object_ptr<Ui::AbstractButton>(parent))
, _shadow(std::make_unique<Ui::PlainShadow>(_wrap.parentWidget())) {
, _shadow(std::make_unique<Ui::PlainShadow>(parent)) {
_wrap.hide(anim::type::instant);
_shadow->hide();

View file

@ -1878,6 +1878,10 @@ void SessionController::showForum(
const SectionShow &params) {
if (showForumInDifferentWindow(forum, params)) {
return;
} else if (HistoryView::SubsectionTabs::UsedFor(
forum->owner().history(forum->channel()))) {
showPeerHistory(forum->channel(), params);
return;
}
_shownForumLifetime.destroy();
if (_shownForum.current() != forum) {