Merge tag 'v5.2.0' into dev

# Conflicts:
#	Telegram/Resources/winrc/Telegram.rc
#	Telegram/Resources/winrc/Updater.rc
#	Telegram/SourceFiles/calls/calls_call.cpp
#	Telegram/SourceFiles/core/version.h
#	Telegram/SourceFiles/history/view/media/history_view_gif.cpp
#	Telegram/SourceFiles/window/notifications_manager_default.cpp
#	Telegram/lib_ui
#	snap/snapcraft.yaml
This commit is contained in:
AlexeyZavar
2024-07-01 03:55:36 +03:00
273 changed files with 7124 additions and 2466 deletions
+93 -45
View File
@@ -99,6 +99,7 @@ namespace {
constexpr auto kSearchPerPage = 50;
constexpr auto kStoriesExpandDuration = crl::time(200);
constexpr auto kSearchRequestDelay = crl::time(900);
base::options::toggle OptionForumHideChatsList({
.id = kOptionForumHideChatsList,
@@ -328,9 +329,9 @@ Widget::Widget(
_scroll->scrollToY(st + _inner->st()->height);
}
}, lifetime());
_inner->searchMessages(
) | rpl::start_with_next([=] {
searchRequested();
_inner->searchRequests(
) | rpl::start_with_next([=](SearchRequestDelay delay) {
searchRequested(delay);
}, lifetime());
_inner->completeHashtagRequests(
) | rpl::start_with_next([=](const QString &tag) {
@@ -565,6 +566,8 @@ void Widget::chosenRow(const ChosenRow &row) {
if (topicJump) {
if (controller()->shownForum().current() == topicJump->forum()) {
controller()->closeForum();
} else if (row.newWindow) {
controller()->showInNewWindow(Window::SeparateId(topicJump));
} else {
if (!controller()->adaptive().isOneColumn()) {
controller()->showForum(
@@ -578,11 +581,17 @@ void Widget::chosenRow(const ChosenRow &row) {
}
return;
} else if (const auto topic = row.key.topic()) {
session().data().saveViewAsMessages(topic->forum(), false);
controller()->showThread(
topic,
row.message.fullId.msg,
Window::SectionShow::Way::ClearStack);
if (row.newWindow) {
controller()->showInNewWindow(
Window::SeparateId(topic),
row.message.fullId.msg);
} else {
session().data().saveViewAsMessages(topic->forum(), false);
controller()->showThread(
topic,
row.message.fullId.msg,
Window::SectionShow::Way::ClearStack);
}
} else if (history
&& row.userpicClick
&& (row.message.fullId.msg == ShowAtUnreadMsgId)
@@ -599,16 +608,19 @@ void Widget::chosenRow(const ChosenRow &row) {
const auto forum = history->peer->forum();
if (controller()->shownForum().current() == forum) {
controller()->closeForum();
return;
}
controller()->showForum(
forum,
Window::SectionShow().withChildColumn());
if (forum->channel()->viewForumAsMessages()) {
controller()->showThread(
history,
ShowAtUnreadMsgId,
Window::SectionShow::Way::ClearStack);
} else if (row.newWindow) {
controller()->showInNewWindow(
Window::SeparateId(Window::SeparateType::Forum, history));
} else {
controller()->showForum(
forum,
Window::SectionShow().withChildColumn());
if (forum->channel()->viewForumAsMessages()) {
controller()->showThread(
history,
ShowAtUnreadMsgId,
Window::SectionShow::Way::ClearStack);
}
}
return;
} else if (history) {
@@ -634,6 +646,12 @@ void Widget::chosenRow(const ChosenRow &row) {
return;
}
}
if (row.newWindow) {
controller()->showInNewWindow(Window::SeparateId(
Window::SeparateType::Archive,
&session()));
return;
}
controller()->openFolder(folder);
hideChildList();
}
@@ -912,13 +930,15 @@ void Widget::setupStories() {
Core::App().settings().setStoriesClickTooltipHidden(true);
Core::App().saveSettingsDelayed();
};
_stories->setShowTooltip(
parentWidget(),
rpl::combine(
Core::App().settings().storiesClickTooltipHiddenValue(),
shownValue(),
!rpl::mappers::_1 && rpl::mappers::_2),
hideTooltip);
InvokeQueued(_stories.get(), [=] {
_stories->setShowTooltip(
controller()->content(),
rpl::combine(
Core::App().settings().storiesClickTooltipHiddenValue(),
shownValue(),
!rpl::mappers::_1 && rpl::mappers::_2),
hideTooltip);
});
}
_storiesContents.fire(Stories::ContentForSession(
@@ -1868,13 +1888,21 @@ void Widget::slideFinished() {
void Widget::escape() {
if (!cancelSearch({ .jumpBackToSearchedChat = true })) {
if (controller()->shownForum().current()) {
controller()->closeForum();
if (const auto forum = controller()->shownForum().current()) {
const auto id = controller()->windowId();
const auto initial = id.forum();
if (!initial) {
controller()->closeForum();
} else if (initial != forum) {
controller()->showForum(initial);
}
} else if (controller()->openedFolder().current()) {
controller()->closeFolder();
if (!controller()->windowId().folder()) {
controller()->closeFolder();
}
} else if (controller()->activeChatEntryCurrent().key) {
controller()->content()->dialogsCancelled();
} else {
} else if (controller()->isPrimary()) {
const auto filters = &session().data().chatsFilters();
const auto &list = filters->list();
const auto first = list.empty() ? FilterId() : list.front().id();
@@ -1945,7 +1973,7 @@ void Widget::loadMoreBlockedByDate() {
session().api().requestMoreBlockedByDateDialogs();
}
bool Widget::search(bool inCache) {
bool Widget::search(bool inCache, SearchRequestDelay delay) {
_processingSearch = true;
const auto guard = gsl::finally([&] {
_processingSearch = false;
@@ -1974,7 +2002,7 @@ bool Widget::search(bool inCache) {
return true;
} else if (inCache) {
const auto success = _singleMessageSearch.lookup(query, [=] {
searchRequested();
searchRequested(delay);
});
if (!success) {
return false;
@@ -2092,6 +2120,9 @@ bool Widget::search(bool inCache) {
}).send();
_searchQueries.emplace(_searchRequest, _searchQuery);
}
_inner->searchRequested(true);
} else {
_inner->searchRequested(false);
}
const auto peerQuery = Api::ConvertPeerSearchQuery(query);
if (searchForPeersRequired(peerQuery)) {
@@ -2143,20 +2174,25 @@ bool Widget::searchForPeersRequired(const QString &query) const {
return _searchState.filterChatsList()
&& !_openedForum
&& !query.isEmpty()
&& !IsHashtagSearchQuery(query);
&& (IsHashOrCashtagSearchQuery(query) == HashOrCashtag::None);
}
bool Widget::searchForTopicsRequired(const QString &query) const {
return _searchState.filterChatsList()
&& _openedForum
&& !query.isEmpty()
&& !IsHashtagSearchQuery(query)
&& (IsHashOrCashtagSearchQuery(query) == HashOrCashtag::None)
&& !_openedForum->topicsList()->loaded();
}
void Widget::searchRequested() {
if (!search(true)) {
_searchTimer.callOnce(AutoSearchTimeout);
void Widget::searchRequested(SearchRequestDelay delay) {
if (search(true, delay)) {
return;
} else if (delay == SearchRequestDelay::Instant) {
_searchTimer.cancel();
search();
} else {
_searchTimer.callOnce(kSearchRequestDelay);
}
}
@@ -2211,10 +2247,11 @@ void Widget::searchTopics() {
}
void Widget::searchMore() {
if (_searchRequest || _searchInHistoryRequest) {
if (_searchRequest
|| _searchInHistoryRequest
|| _searchTimer.isActive()) {
return;
}
if (!_searchFull) {
} else if (!_searchFull) {
if (const auto peer = searchInPeer()) {
auto &histories = session().data().histories();
const auto topic = searchInTopic();
@@ -2666,16 +2703,19 @@ void Widget::updateCancelSearch() {
QString Widget::validateSearchQuery() {
const auto query = currentSearchQuery();
if (_searchState.tab == ChatSearchTab::PublicPosts) {
_searchingHashtag = true;
if (_searchHashOrCashtag == HashOrCashtag::None) {
_searchHashOrCashtag = HashOrCashtag::Hashtag;
}
const auto fixed = FixHashtagSearchQuery(
query,
currentSearchQueryCursorPosition());
currentSearchQueryCursorPosition(),
_searchHashOrCashtag);
if (fixed.text != query) {
setSearchQuery(fixed.text, fixed.cursorPosition);
}
return fixed.text;
} else {
_searchingHashtag = IsHashtagSearchQuery(query);
_searchHashOrCashtag = IsHashOrCashtagSearchQuery(query);
}
return query;
}
@@ -2713,6 +2753,9 @@ void Widget::updateForceDisplayWide() {
void Widget::showForum(
not_null<Data::Forum*> forum,
const Window::SectionShow &params) {
if (_openedForum == forum) {
return;
}
const auto nochat = !controller()->mainSectionShown();
if (!params.childColumn
|| (Core::App().settings().dialogsWidthRatio(nochat) == 0.)
@@ -2872,11 +2915,12 @@ bool Widget::applySearchState(SearchState state) {
state.fromPeer = nullptr;
}
if (state.tab == ChatSearchTab::PublicPosts
&& !IsHashtagSearchQuery(state.query)) {
&& IsHashOrCashtagSearchQuery(state.query) == HashOrCashtag::None) {
state.tab = (_openedForum && !state.inChat)
? ChatSearchTab::ThisPeer
: ChatSearchTab::MyMessages;
} else if (!state.inChat && !_searchingHashtag) {
} else if (!state.inChat
&& _searchHashOrCashtag == HashOrCashtag::None) {
state.tab = (forum || _openedForum)
? ChatSearchTab::ThisPeer
: ChatSearchTab::MyMessages;
@@ -2916,7 +2960,7 @@ bool Widget::applySearchState(SearchState state) {
&& !state.inChat
&& !_openedForum)
|| (state.tab == ChatSearchTab::PublicPosts
&& !_searchingHashtag)) {
&& _searchHashOrCashtag == HashOrCashtag::None)) {
state.tab = state.inChat.topic()
? ChatSearchTab::ThisTopic
: (state.inChat.owningHistory() || state.inChat.sublist())
@@ -3648,7 +3692,11 @@ bool Widget::cancelSearch(CancelSearchOptions options) {
_inner->clearFilter();
applySearchState(std::move(updatedState));
if (_suggestions && clearSearchFocus) {
const auto clearLockedFocus = !_searchHasFocus;
setInnerFocus(true);
if (clearLockedFocus) {
processSearchFocusChange();
}
}
updateForceDisplayWide();
return clearingQuery || clearingInChat || clearSearchFocus;