mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-08 08:07:10 +00:00
Added ability to invoke callback for non-primary window controllers.
This commit is contained in:
parent
f78b9324dc
commit
6ca167679d
@ -194,7 +194,8 @@ bool Widget::floatPlayerIsVisible(not_null<HistoryItem*> item) {
|
||||
void Widget::floatPlayerDoubleClickEvent(not_null<const HistoryItem*> item) {
|
||||
getData()->controller->invokeForSessionController(
|
||||
&item->history()->peer->session().account(),
|
||||
[=](not_null<Window::SessionController*> controller) {
|
||||
item->history()->peer,
|
||||
[&](not_null<Window::SessionController*> controller) {
|
||||
controller->showPeerHistoryAtItem(item);
|
||||
});
|
||||
}
|
||||
|
@ -4735,16 +4735,17 @@ Window::SessionController *OverlayWidget::findWindow(bool switchTo) const {
|
||||
}
|
||||
}
|
||||
|
||||
const auto &active = _session->windows();
|
||||
if (!active.empty()) {
|
||||
return active.front();
|
||||
} else if (window && switchTo) {
|
||||
Window::SessionController *controllerPtr = nullptr;
|
||||
window->invokeForSessionController(
|
||||
&_session->account(),
|
||||
[&](not_null<Window::SessionController*> newController) {
|
||||
controllerPtr = newController;
|
||||
});
|
||||
if (switchTo) {
|
||||
auto controllerPtr = (Window::SessionController*)nullptr;
|
||||
const auto anyWindow = window ? window : Core::App().primaryWindow();
|
||||
if (anyWindow) {
|
||||
anyWindow->invokeForSessionController(
|
||||
&_session->account(),
|
||||
_history ? _history->peer : nullptr,
|
||||
[&](not_null<Window::SessionController*> newController) {
|
||||
controllerPtr = newController;
|
||||
});
|
||||
}
|
||||
return controllerPtr;
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,17 @@ void Controller::preventOrInvoke(Fn<void()> &&callback) {
|
||||
|
||||
void Controller::invokeForSessionController(
|
||||
not_null<Main::Account*> account,
|
||||
PeerData *singlePeer,
|
||||
Fn<void(not_null<SessionController*>)> &&callback) {
|
||||
const auto separateWindow = singlePeer
|
||||
? Core::App().separateWindowForPeer(singlePeer)
|
||||
: nullptr;
|
||||
const auto separateSession = separateWindow
|
||||
? separateWindow->sessionController()
|
||||
: nullptr;
|
||||
if (separateSession) {
|
||||
return callback(separateSession);
|
||||
}
|
||||
_account->domain().activate(std::move(account));
|
||||
if (_sessionController) {
|
||||
callback(_sessionController.get());
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
|
||||
void invokeForSessionController(
|
||||
not_null<Main::Account*> account,
|
||||
PeerData *singlePeer,
|
||||
Fn<void(not_null<SessionController*>)> &&callback);
|
||||
|
||||
void openInMediaView(Media::View::OpenRequest &&request);
|
||||
|
@ -1466,7 +1466,8 @@ void SessionController::showPeerHistoryAtItem(
|
||||
not_null<const HistoryItem*> item) {
|
||||
_window->invokeForSessionController(
|
||||
&item->history()->peer->session().account(),
|
||||
[=](not_null<SessionController*> controller) {
|
||||
item->history()->peer,
|
||||
[&](not_null<SessionController*> controller) {
|
||||
if (item->isScheduled()) {
|
||||
controller->showSection(
|
||||
std::make_shared<HistoryView::ScheduledMemento>(
|
||||
|
Loading…
Reference in New Issue
Block a user