mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
parent
24d3bcb590
commit
377b86372b
3 changed files with 35 additions and 6 deletions
|
@ -123,7 +123,7 @@ public:
|
||||||
[[nodiscard]] MsgId lastSearchMigratedId() const;
|
[[nodiscard]] MsgId lastSearchMigratedId() const;
|
||||||
|
|
||||||
[[nodiscard]] WidgetState state() const;
|
[[nodiscard]] WidgetState state() const;
|
||||||
[[nodiscard]] const style::DialogRow *st() const {
|
[[nodiscard]] not_null<const style::DialogRow*> st() const {
|
||||||
return _st;
|
return _st;
|
||||||
}
|
}
|
||||||
[[nodiscard]] bool waitingForSearch() const {
|
[[nodiscard]] bool waitingForSearch() const {
|
||||||
|
|
|
@ -208,8 +208,19 @@ Widget::Widget(
|
||||||
|
|
||||||
session().changes().historyUpdates(
|
session().changes().historyUpdates(
|
||||||
Data::HistoryUpdate::Flag::MessageSent
|
Data::HistoryUpdate::Flag::MessageSent
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::filter([=](const Data::HistoryUpdate &update) {
|
||||||
jumpToTop();
|
if (_openedForum) {
|
||||||
|
return (update.history->peer == _openedForum);
|
||||||
|
} else if (_openedFolder) {
|
||||||
|
return (update.history->folder() == _openedFolder)
|
||||||
|
&& !update.history->isPinnedDialog(FilterId());
|
||||||
|
} else {
|
||||||
|
return !update.history->folder()
|
||||||
|
&& !update.history->isPinnedDialog(
|
||||||
|
controller->activeChatsFilterCurrent());
|
||||||
|
}
|
||||||
|
}) | rpl::start_with_next([=](const Data::HistoryUpdate &update) {
|
||||||
|
jumpToTop(true);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
fullSearchRefreshOn(session().settings().skipArchiveInSearchChanges(
|
fullSearchRefreshOn(session().settings().skipArchiveInSearchChanges(
|
||||||
|
@ -764,13 +775,31 @@ void Widget::setInnerFocus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::jumpToTop() {
|
void Widget::jumpToTop(bool belowPinned) {
|
||||||
if (session().supportMode()) {
|
if (session().supportMode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((_filter->getLastText().trimmed().isEmpty() && !_searchInChat)) {
|
if ((_filter->getLastText().trimmed().isEmpty() && !_searchInChat)) {
|
||||||
|
auto to = 0;
|
||||||
|
if (belowPinned) {
|
||||||
|
const auto list = _openedForum
|
||||||
|
? _openedForum->forum()->topicsList()
|
||||||
|
: controller()->activeChatsFilterCurrent()
|
||||||
|
? session().data().chatsFilters().chatsList(
|
||||||
|
controller()->activeChatsFilterCurrent())
|
||||||
|
: session().data().chatsList(_openedFolder);
|
||||||
|
const auto count = int(list->pinned()->order().size());
|
||||||
|
const auto now = _scroll->scrollTop();
|
||||||
|
const auto row = _inner->st()->height;
|
||||||
|
const auto min = (row * (count * 2 + 1) - _scroll->height()) / 2;
|
||||||
|
if (_scroll->scrollTop() <= min) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Don't jump too high up, below the pinned chats.
|
||||||
|
to = std::max(min, to);
|
||||||
|
}
|
||||||
_scrollToAnimation.stop();
|
_scrollToAnimation.stop();
|
||||||
_scroll->scrollToY(0);
|
_scroll->scrollToY(to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
void searchInChat(Key chat);
|
void searchInChat(Key chat);
|
||||||
void setInnerFocus();
|
void setInnerFocus();
|
||||||
|
|
||||||
void jumpToTop();
|
void jumpToTop(bool belowPinned = false);
|
||||||
|
|
||||||
void startWidthAnimation();
|
void startWidthAnimation();
|
||||||
void stopWidthAnimation();
|
void stopWidthAnimation();
|
||||||
|
|
Loading…
Add table
Reference in a new issue