mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve forum search support.
This commit is contained in:
parent
701bf0d553
commit
7d61ab9412
3 changed files with 29 additions and 7 deletions
|
@ -615,6 +615,7 @@ void Widget::chosenRow(const ChosenRow &row) {
|
||||||
escape();
|
escape();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateForceDisplayWide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setGeometryWithTopMoved(
|
void Widget::setGeometryWithTopMoved(
|
||||||
|
@ -1234,7 +1235,9 @@ void Widget::updateSearchTabs() {
|
||||||
_searchState.tab);
|
_searchState.tab);
|
||||||
_searchTabs->setVisible(!_showAnimation);
|
_searchTabs->setVisible(!_showAnimation);
|
||||||
_searchTabs->tabChanges(
|
_searchTabs->tabChanges(
|
||||||
) | rpl::start_with_next([=](ChatSearchTab tab) {
|
) | rpl::filter([=](ChatSearchTab tab) {
|
||||||
|
return (_searchState.tab != tab);
|
||||||
|
}) | rpl::start_with_next([=](ChatSearchTab tab) {
|
||||||
auto copy = _searchState;
|
auto copy = _searchState;
|
||||||
copy.tab = tab;
|
copy.tab = tab;
|
||||||
applySearchState(std::move(copy));
|
applySearchState(std::move(copy));
|
||||||
|
@ -1244,6 +1247,8 @@ void Widget::updateSearchTabs() {
|
||||||
const auto topic = _searchState.inChat.topic();
|
const auto topic = _searchState.inChat.topic();
|
||||||
const auto peer = _searchState.inChat.owningHistory()
|
const auto peer = _searchState.inChat.owningHistory()
|
||||||
? _searchState.inChat.owningHistory()->peer.get()
|
? _searchState.inChat.owningHistory()->peer.get()
|
||||||
|
: _openedForum
|
||||||
|
? _openedForum->channel().get()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
const auto topicShortLabel = topic
|
const auto topicShortLabel = topic
|
||||||
? Ui::Text::SingleCustomEmoji(Data::TopicIconEmojiEntity({
|
? Ui::Text::SingleCustomEmoji(Data::TopicIconEmojiEntity({
|
||||||
|
@ -1271,7 +1276,8 @@ void Widget::updateSearchTabs() {
|
||||||
if ((_searchState.tab == ChatSearchTab::ThisTopic
|
if ((_searchState.tab == ChatSearchTab::ThisTopic
|
||||||
&& !_searchState.inChat.topic())
|
&& !_searchState.inChat.topic())
|
||||||
|| (_searchState.tab == ChatSearchTab::ThisPeer
|
|| (_searchState.tab == ChatSearchTab::ThisPeer
|
||||||
&& !_searchState.inChat)
|
&& !_searchState.inChat
|
||||||
|
&& !_openedForum)
|
||||||
|| (_searchState.tab == ChatSearchTab::PublicPosts
|
|| (_searchState.tab == ChatSearchTab::PublicPosts
|
||||||
&& !_searchingHashtag)) {
|
&& !_searchingHashtag)) {
|
||||||
_searchState.tab = _searchState.inChat.topic()
|
_searchState.tab = _searchState.inChat.topic()
|
||||||
|
@ -1960,6 +1966,12 @@ void Widget::loadMoreBlockedByDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Widget::search(bool inCache) {
|
bool Widget::search(bool inCache) {
|
||||||
|
_processingSearch = true;
|
||||||
|
const auto guard = gsl::finally([&] {
|
||||||
|
_processingSearch = false;
|
||||||
|
listScrollUpdated();
|
||||||
|
});
|
||||||
|
|
||||||
auto result = false;
|
auto result = false;
|
||||||
const auto query = _searchState.query.trimmed();
|
const auto query = _searchState.query.trimmed();
|
||||||
const auto inPeer = searchInPeer();
|
const auto inPeer = searchInPeer();
|
||||||
|
@ -2710,6 +2722,10 @@ void Widget::applySearchUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::updateForceDisplayWide() {
|
void Widget::updateForceDisplayWide() {
|
||||||
|
if (_childList) {
|
||||||
|
_childList->updateForceDisplayWide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
controller()->setChatsForceDisplayWide(_searchHasFocus
|
controller()->setChatsForceDisplayWide(_searchHasFocus
|
||||||
|| (_subsectionTopBar && _subsectionTopBar->searchHasFocus())
|
|| (_subsectionTopBar && _subsectionTopBar->searchHasFocus())
|
||||||
|| _searchSuggestionsLocked
|
|| _searchSuggestionsLocked
|
||||||
|
@ -2791,6 +2807,7 @@ void Widget::openChildList(
|
||||||
if (hasFocus()) {
|
if (hasFocus()) {
|
||||||
setInnerFocus();
|
setInnerFocus();
|
||||||
}
|
}
|
||||||
|
updateForceDisplayWide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::closeChildList(anim::type animated) {
|
void Widget::closeChildList(anim::type animated) {
|
||||||
|
@ -2846,6 +2863,7 @@ void Widget::closeChildList(anim::type animated) {
|
||||||
_childListShadow = nullptr;
|
_childListShadow = nullptr;
|
||||||
}
|
}
|
||||||
updateStoriesVisibility();
|
updateStoriesVisibility();
|
||||||
|
updateForceDisplayWide();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Widget::applySearchState(SearchState state) {
|
bool Widget::applySearchState(SearchState state) {
|
||||||
|
@ -2970,8 +2988,10 @@ bool Widget::applySearchState(SearchState state) {
|
||||||
}
|
}
|
||||||
if (!_searchState.inChat && _searchState.query.isEmpty()) {
|
if (!_searchState.inChat && _searchState.query.isEmpty()) {
|
||||||
setInnerFocus();
|
setInnerFocus();
|
||||||
} else if (!_subsectionTopBar || !_subsectionTopBar->searchSetFocus()) {
|
} else if (!_subsectionTopBar) {
|
||||||
_search->setFocus();
|
_search->setFocus();
|
||||||
|
} else if (_openedForum && !_subsectionTopBar->searchSetFocus()) {
|
||||||
|
_subsectionTopBar->toggleSearch(true, anim::type::normal);
|
||||||
}
|
}
|
||||||
updateForceDisplayWide();
|
updateForceDisplayWide();
|
||||||
applySearchUpdate();
|
applySearchUpdate();
|
||||||
|
@ -3633,6 +3653,7 @@ bool Widget::cancelSearch() {
|
||||||
if (_suggestions && clearSearchFocus) {
|
if (_suggestions && clearSearchFocus) {
|
||||||
setInnerFocus(true);
|
setInnerFocus(true);
|
||||||
}
|
}
|
||||||
|
updateForceDisplayWide();
|
||||||
return clearingQuery || clearingInChat || clearSearchFocus;
|
return clearingQuery || clearingInChat || clearSearchFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -319,6 +319,7 @@ private:
|
||||||
QString _lastSearchText;
|
QString _lastSearchText;
|
||||||
bool _searchSuggestionsLocked = false;
|
bool _searchSuggestionsLocked = false;
|
||||||
bool _searchHasFocus = false;
|
bool _searchHasFocus = false;
|
||||||
|
bool _processingSearch = false;
|
||||||
|
|
||||||
rpl::event_stream<rpl::producer<Stories::Content>> _storiesContents;
|
rpl::event_stream<rpl::producer<Stories::Content>> _storiesContents;
|
||||||
base::flat_map<PeerId, Ui::PeerUserpicView> _storiesUserpicsViewsHidden;
|
base::flat_map<PeerId, Ui::PeerUserpicView> _storiesUserpicsViewsHidden;
|
||||||
|
|
|
@ -114,13 +114,13 @@ ChatSearchTabs::ChatSearchTabs(QWidget *parent, ChatSearchTab active)
|
||||||
_tabs->sectionActivated(
|
_tabs->sectionActivated(
|
||||||
) | rpl::start_with_next([=](int index) {
|
) | rpl::start_with_next([=](int index) {
|
||||||
for (const auto &tab : _list) {
|
for (const auto &tab : _list) {
|
||||||
if (!index) {
|
if (tab.shortLabel.empty()) {
|
||||||
|
continue;
|
||||||
|
} else if (!index) {
|
||||||
_active = tab.value;
|
_active = tab.value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!tab.shortLabel.empty()) {
|
--index;
|
||||||
--index;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue