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

Don't push sublists to stack endlessly.

This commit is contained in:
John Preston
2024-01-02 14:48:51 +04:00
parent bdf67645bb
commit 382dab4ecb
7 changed files with 37 additions and 7 deletions

View File

@@ -1379,7 +1379,7 @@ void MainWidget::showHistory(
if (!back && (way != Way::ClearStack)) {
// This may modify the current section, for example remove its contents.
saveSectionInStack();
saveSectionInStack(params);
}
if (_history->peer()
@@ -1501,13 +1501,23 @@ Ui::ChatTheme *MainWidget::customChatTheme() const {
return _history->customChatTheme();
}
void MainWidget::saveSectionInStack() {
bool MainWidget::saveSectionInStack(
const SectionShow &params,
Window::SectionWidget *newMainSection) {
if (_mainSection) {
if (auto memento = _mainSection->createMemento()) {
if (params.dropSameFromStack
&& newMainSection
&& newMainSection->sameTypeAs(memento.get())) {
// When choosing saved sublist we want to save the original
// "Saved Messages" in the stack, but don't save every
// sublist in a new stack entry when clicking them through.
return false;
}
_stack.push_back(std::make_unique<StackItemSection>(
std::move(memento)));
} else {
return;
return false;
}
} else if (const auto history = _history->history()) {
_stack.push_back(std::make_unique<StackItemHistory>(
@@ -1515,7 +1525,7 @@ void MainWidget::saveSectionInStack() {
_history->msgId(),
_history->replyReturns()));
} else {
return;
return false;
}
const auto raw = _stack.back().get();
raw->setThirdSectionWeak(_thirdSection.data());
@@ -1528,6 +1538,7 @@ void MainWidget::saveSectionInStack() {
}
}
}, raw->lifetime());
return true;
}
void MainWidget::showSection(
@@ -1730,7 +1741,11 @@ void MainWidget::showNewSection(
if (saveInStack) {
// This may modify the current section, for example remove its contents.
saveSectionInStack();
if (!saveSectionInStack(params, newMainSection)) {
saveInStack = false;
animatedShow = false;
animationParams = Window::SectionSlideParams();
}
}
auto &settingSection = newThirdSection
? _thirdSection