2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Added saving of scroll state in dialogs widget between chats filters.

This commit is contained in:
23rd
2022-11-01 10:46:31 +03:00
committed by John Preston
parent c6aba83a6b
commit 03c08ad95f
2 changed files with 19 additions and 4 deletions

View File

@@ -2954,10 +2954,11 @@ bool InnerWidget::chooseCollapsedRow() {
}
void InnerWidget::switchToFilter(FilterId filterId) {
const auto found = filterId && ranges::contains(
session().data().chatsFilters().list(),
filterId,
&Data::ChatFilter::id);
const auto &list = session().data().chatsFilters().list();
const auto filterIt = filterId
? ranges::find(list, filterId, &Data::ChatFilter::id)
: end(list);
const auto found = (filterIt != end(list));
if (!found) {
filterId = 0;
}
@@ -2965,6 +2966,7 @@ void InnerWidget::switchToFilter(FilterId filterId) {
_mustScrollTo.fire({ 0, 0 });
return;
}
_chatsFilterScrollStates[_filterId] = -pos().y();
if (_openedFolder) {
_filterId = filterId;
} else {
@@ -2974,6 +2976,17 @@ void InnerWidget::switchToFilter(FilterId filterId) {
refreshWithCollapsedRows(true);
}
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() {