mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Added initial implementation of display sections prevent.
This commit is contained in:
@@ -1403,6 +1403,7 @@ void MainWidget::ui_showPeerHistory(
|
||||
PeerId peerId,
|
||||
const SectionShow ¶ms,
|
||||
MsgId showAtMsgId) {
|
||||
|
||||
if (auto peer = session().data().peerLoaded(peerId)) {
|
||||
if (peer->migrateTo()) {
|
||||
peer = peer->migrateTo();
|
||||
@@ -1423,6 +1424,13 @@ void MainWidget::ui_showPeerHistory(
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(_history->peer() && _history->peer()->id == peerId)
|
||||
&& preventsCloseSection(
|
||||
[=] { ui_showPeerHistory(peerId, params, showAtMsgId); },
|
||||
params)) {
|
||||
return;
|
||||
}
|
||||
|
||||
using OriginMessage = SectionShow::OriginMessage;
|
||||
if (const auto origin = std::get_if<OriginMessage>(¶ms.origin)) {
|
||||
if (const auto returnTo = session().data().message(origin->id)) {
|
||||
@@ -1618,13 +1626,22 @@ void MainWidget::showSection(
|
||||
// return;
|
||||
}
|
||||
|
||||
using MementoPtr = std::unique_ptr<Window::SectionMemento>;
|
||||
const auto sharedMemento = std::make_shared<MementoPtr>(
|
||||
std::move(memento));
|
||||
if (preventsCloseSection(
|
||||
[=] { showSection(base::take(*sharedMemento), params); },
|
||||
params)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the window was not resized, but we've enabled
|
||||
// tabbedSelectorSectionEnabled or thirdSectionInfoEnabled
|
||||
// we need to update adaptive layout to Adaptive::ThirdColumn().
|
||||
updateColumnLayout();
|
||||
|
||||
showNewSection(
|
||||
std::move(memento),
|
||||
std::move(*sharedMemento),
|
||||
params);
|
||||
}
|
||||
|
||||
@@ -1880,8 +1897,24 @@ bool MainWidget::stackIsEmpty() const {
|
||||
return _stack.empty();
|
||||
}
|
||||
|
||||
bool MainWidget::preventsCloseSection(
|
||||
Fn<void()> callback,
|
||||
const SectionShow ¶ms) const {
|
||||
if (params.thirdColumn || Core::App().passcodeLocked()) {
|
||||
return false;
|
||||
}
|
||||
auto copy = callback;
|
||||
return (_mainSection && _mainSection->preventsClose(std::move(copy)))
|
||||
|| (_history && _history->preventsClose(std::move(callback)));
|
||||
}
|
||||
|
||||
void MainWidget::showBackFromStack(
|
||||
const SectionShow ¶ms) {
|
||||
|
||||
if (preventsCloseSection([=] { showBackFromStack(params); }, params)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectingPeer()) {
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user