mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Don't push sublists to stack endlessly.
This commit is contained in:
parent
bdf67645bb
commit
382dab4ecb
7 changed files with 37 additions and 7 deletions
|
@ -293,6 +293,10 @@ bool SublistWidget::showInternal(
|
|||
return false;
|
||||
}
|
||||
|
||||
bool SublistWidget::sameTypeAs(not_null<Window::SectionMemento*> memento) {
|
||||
return dynamic_cast<SublistMemento*>(memento.get()) != nullptr;
|
||||
}
|
||||
|
||||
void SublistWidget::setInternalState(
|
||||
const QRect &geometry,
|
||||
not_null<SublistMemento*> memento) {
|
||||
|
|
|
@ -58,6 +58,8 @@ public:
|
|||
bool showInternal(
|
||||
not_null<Window::SectionMemento*> memento,
|
||||
const Window::SectionShow ¶ms) override;
|
||||
bool sameTypeAs(not_null<Window::SectionMemento*> memento) override;
|
||||
|
||||
std::shared_ptr<Window::SectionMemento> createMemento() override;
|
||||
bool showMessage(
|
||||
PeerId peerId,
|
||||
|
|
|
@ -60,9 +60,12 @@ SublistsWidget::SublistsWidget(
|
|||
|
||||
_list->chosenRow() | rpl::start_with_next([=](Dialogs::ChosenRow row) {
|
||||
if (const auto sublist = row.key.sublist()) {
|
||||
using namespace Window;
|
||||
auto params = SectionShow(SectionShow::Way::Forward);
|
||||
params.dropSameFromStack = true;
|
||||
controller->showSection(
|
||||
std::make_shared<HistoryView::SublistMemento>(sublist),
|
||||
Window::SectionShow::Way::Forward);
|
||||
params);
|
||||
}
|
||||
}, _list->lifetime());
|
||||
|
||||
|
|
|
@ -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 ¶ms,
|
||||
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
|
||||
|
|
|
@ -286,7 +286,9 @@ private:
|
|||
Window::SectionSlideParams prepareHistoryAnimation(PeerId historyPeerId);
|
||||
Window::SectionSlideParams prepareDialogsAnimation();
|
||||
|
||||
void saveSectionInStack();
|
||||
bool saveSectionInStack(
|
||||
const SectionShow ¶ms,
|
||||
Window::SectionWidget *newMainSection = nullptr);
|
||||
|
||||
int getMainSectionTop() const;
|
||||
int getThirdSectionTop() const;
|
||||
|
|
|
@ -138,6 +138,9 @@ public:
|
|||
virtual bool showInternal(
|
||||
not_null<SectionMemento*> memento,
|
||||
const SectionShow ¶ms) = 0;
|
||||
virtual bool sameTypeAs(not_null<SectionMemento*> memento) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool showMessage(
|
||||
PeerId peerId,
|
||||
|
|
|
@ -162,6 +162,7 @@ struct SectionShow {
|
|||
bool childColumn = false;
|
||||
bool forbidLayer = false;
|
||||
bool reapplyLocalDraft = false;
|
||||
bool dropSameFromStack = false;
|
||||
Origin origin;
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue