mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Added saving of scroll state in dialogs widget for restoring from forum.
This commit is contained in:
parent
c320917069
commit
629314cfa2
3 changed files with 27 additions and 11 deletions
Telegram/SourceFiles
|
@ -426,6 +426,9 @@ void InnerWidget::changeOpenedForum(ChannelData *forum) {
|
|||
stopReorderPinned();
|
||||
clearSelection();
|
||||
|
||||
if (forum) {
|
||||
saveChatsFilterScrollState(_filterId);
|
||||
}
|
||||
_filterId = forum
|
||||
? 0
|
||||
: _controller->activeChatsFilterCurrent();
|
||||
|
@ -450,6 +453,10 @@ void InnerWidget::changeOpenedForum(ChannelData *forum) {
|
|||
if (_loadMoreCallback) {
|
||||
_loadMoreCallback();
|
||||
}
|
||||
|
||||
if (!forum) {
|
||||
restoreChatsFilterScrollState(_filterId);
|
||||
}
|
||||
}
|
||||
|
||||
void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||
|
@ -2971,7 +2978,7 @@ void InnerWidget::switchToFilter(FilterId filterId) {
|
|||
_mustScrollTo.fire({ 0, 0 });
|
||||
return;
|
||||
}
|
||||
_chatsFilterScrollStates[_filterId] = -pos().y();
|
||||
saveChatsFilterScrollState(_filterId);
|
||||
if (_openedFolder) {
|
||||
_filterId = filterId;
|
||||
} else {
|
||||
|
@ -2982,18 +2989,26 @@ void InnerWidget::switchToFilter(FilterId filterId) {
|
|||
}
|
||||
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 });
|
||||
}
|
||||
const auto skip = found
|
||||
// Don't save a scroll state for very flexible chat filters.
|
||||
&& (filterIt->flags() & (Data::ChatFilter::Flag::NoRead));
|
||||
if (!skip) {
|
||||
restoreChatsFilterScrollState(filterId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InnerWidget::saveChatsFilterScrollState(FilterId filterId) {
|
||||
_chatsFilterScrollStates[filterId] = -pos().y();
|
||||
}
|
||||
|
||||
void InnerWidget::restoreChatsFilterScrollState(FilterId filterId) {
|
||||
const auto it = _chatsFilterScrollStates.find(filterId);
|
||||
if (it != end(_chatsFilterScrollStates)) {
|
||||
_mustScrollTo.fire({ it->second, -1 });
|
||||
}
|
||||
}
|
||||
|
||||
bool InnerWidget::chooseHashtag() {
|
||||
if (_state != WidgetState::Filtered) {
|
||||
return false;
|
||||
|
|
|
@ -357,6 +357,9 @@ private:
|
|||
void handleChatListEntryRefreshes();
|
||||
void moveCancelSearchButtons();
|
||||
|
||||
void saveChatsFilterScrollState(FilterId filterId);
|
||||
void restoreChatsFilterScrollState(FilterId filterId);
|
||||
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
|
||||
FilterId _filterId = 0;
|
||||
|
|
|
@ -17,8 +17,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/text_options.h"
|
||||
|
||||
TextForMimeData HistoryItemText(not_null<HistoryItem*> item) {
|
||||
const auto media = item->media();
|
||||
|
||||
auto textResult = item->clipboardText();
|
||||
auto logEntryOriginalResult = [&] {
|
||||
const auto entry = item->Get<HistoryMessageLogEntryOriginal>();
|
||||
|
|
Loading…
Add table
Reference in a new issue