From 106bdae9ceac4176551db9614c6560fb6bd41e18 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 21 Nov 2022 16:42:52 +0000 Subject: [PATCH] Always open first topic in two-column layout. --- .../dialogs/dialogs_inner_widget.cpp | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index f9a5d15e5..8668bcb9c 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -3212,13 +3212,24 @@ bool InnerWidget::chooseRow( if (IsServerMsgId(chosen.message.fullId.msg)) { session().local().saveRecentSearchHashtags(_filter); } - if (pressedTopicRootId && !chosen.message.fullId) { - const auto history = chosen.key.history(); - if (history->peer->isForum()) { - chosen.message.fullId = { - history->peer->id, - pressedTopicRootId, - }; + if (!chosen.message.fullId) { + if (const auto history = chosen.key.history()) { + if (const auto forum = history->peer->forum()) { + if (pressedTopicRootId) { + chosen.message.fullId = { + history->peer->id, + pressedTopicRootId, + }; + } else if (!_controller->adaptive().isOneColumn()) { + const auto &recent = forum->recentTopics(); + if (!recent.empty()) { + chosen.message.fullId = { + history->peer->id, + recent.front()->rootId(), + }; + } + } + } } } _chosenRow.fire_copy(chosen);