mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added saving of scroll state in dialogs widget between chats filters.
This commit is contained in:
parent
c6aba83a6b
commit
03c08ad95f
2 changed files with 19 additions and 4 deletions
|
@ -2954,10 +2954,11 @@ bool InnerWidget::chooseCollapsedRow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::switchToFilter(FilterId filterId) {
|
void InnerWidget::switchToFilter(FilterId filterId) {
|
||||||
const auto found = filterId && ranges::contains(
|
const auto &list = session().data().chatsFilters().list();
|
||||||
session().data().chatsFilters().list(),
|
const auto filterIt = filterId
|
||||||
filterId,
|
? ranges::find(list, filterId, &Data::ChatFilter::id)
|
||||||
&Data::ChatFilter::id);
|
: end(list);
|
||||||
|
const auto found = (filterIt != end(list));
|
||||||
if (!found) {
|
if (!found) {
|
||||||
filterId = 0;
|
filterId = 0;
|
||||||
}
|
}
|
||||||
|
@ -2965,6 +2966,7 @@ void InnerWidget::switchToFilter(FilterId filterId) {
|
||||||
_mustScrollTo.fire({ 0, 0 });
|
_mustScrollTo.fire({ 0, 0 });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_chatsFilterScrollStates[_filterId] = -pos().y();
|
||||||
if (_openedFolder) {
|
if (_openedFolder) {
|
||||||
_filterId = filterId;
|
_filterId = filterId;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2974,6 +2976,17 @@ void InnerWidget::switchToFilter(FilterId filterId) {
|
||||||
refreshWithCollapsedRows(true);
|
refreshWithCollapsedRows(true);
|
||||||
}
|
}
|
||||||
refreshEmptyLabel();
|
refreshEmptyLabel();
|
||||||
|
{
|
||||||
|
const auto it = _chatsFilterScrollStates.find(filterId);
|
||||||
|
if (it != end(_chatsFilterScrollStates)) {
|
||||||
|
const auto skip = found
|
||||||
|
// Don't save a scroll state for very flexible chat filters.
|
||||||
|
&& (filterIt->flags() & (Data::ChatFilter::Flag::NoRead));
|
||||||
|
if (!skip) {
|
||||||
|
_mustScrollTo.fire({ it->second, -1 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InnerWidget::chooseHashtag() {
|
bool InnerWidget::chooseHashtag() {
|
||||||
|
|
|
@ -443,6 +443,8 @@ private:
|
||||||
not_null<PeerData*>,
|
not_null<PeerData*>,
|
||||||
std::unique_ptr<Ui::VideoUserpic>> _videoUserpics;
|
std::unique_ptr<Ui::VideoUserpic>> _videoUserpics;
|
||||||
|
|
||||||
|
base::flat_map<FilterId, int> _chatsFilterScrollStates;
|
||||||
|
|
||||||
Fn<void()> _loadMoreCallback;
|
Fn<void()> _loadMoreCallback;
|
||||||
Fn<void()> _loadMoreFilteredCallback;
|
Fn<void()> _loadMoreFilteredCallback;
|
||||||
rpl::event_stream<> _listBottomReached;
|
rpl::event_stream<> _listBottomReached;
|
||||||
|
|
Loading…
Add table
Reference in a new issue