mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-04-01 00:08:02 +00:00
Improved management of online status from non-primary windows.
– The online status of the user should be checked and updated only when the previous active window and the current active window both have different sessions. – Removed MainWindow::activeChangedHook since windows should not change online status on their own on activating. – Renamed Application::maybeActiveSession to Application::maybePrimarySession. – Added updating of online status on changing of the current account since this seems to have been missed.
This commit is contained in:
parent
1d475ee727
commit
fe7cffc509
Telegram/SourceFiles
@ -781,7 +781,7 @@ void Application::checkLocalTime() {
|
||||
base::ConcurrentTimerEnvironment::Adjust();
|
||||
base::unixtime::http_invalidate();
|
||||
}
|
||||
if (const auto session = maybeActiveSession()) {
|
||||
if (const auto session = maybePrimarySession()) {
|
||||
session->updates().checkLastUpdate(adjusted);
|
||||
}
|
||||
}
|
||||
@ -797,6 +797,14 @@ void Application::handleAppDeactivated() {
|
||||
if (_primaryWindow) {
|
||||
_primaryWindow->updateIsActiveBlur();
|
||||
}
|
||||
if (_domain->started()) {
|
||||
const auto session = _lastActiveWindow
|
||||
? _lastActiveWindow->account().maybeSession()
|
||||
: nullptr;
|
||||
if (session) {
|
||||
session->updates().updateOnline();
|
||||
}
|
||||
}
|
||||
Ui::Tooltip::Hide();
|
||||
}
|
||||
|
||||
@ -854,7 +862,7 @@ Main::Account &Application::activeAccount() const {
|
||||
return _domain->active();
|
||||
}
|
||||
|
||||
Main::Session *Application::maybeActiveSession() const {
|
||||
Main::Session *Application::maybePrimarySession() const {
|
||||
return _domain->started() ? activeAccount().maybeSession() : nullptr;
|
||||
}
|
||||
|
||||
@ -1050,7 +1058,7 @@ bool Application::passcodeLocked() const {
|
||||
|
||||
void Application::updateNonIdle() {
|
||||
_lastNonIdleTime = crl::now();
|
||||
if (const auto session = maybeActiveSession()) {
|
||||
if (const auto session = maybePrimarySession()) {
|
||||
session->updates().checkIdleFinish(_lastNonIdleTime);
|
||||
}
|
||||
}
|
||||
@ -1124,11 +1132,9 @@ bool Application::hasActiveWindow(not_null<Main::Session*> session) const {
|
||||
return false;
|
||||
} else if (_calls->hasActivePanel(session)) {
|
||||
return true;
|
||||
} else if (const auto controller = _primaryWindow->sessionController()) {
|
||||
if (&controller->session() == session
|
||||
&& _primaryWindow->widget()->isActive()) {
|
||||
return true;
|
||||
}
|
||||
} else if (const auto window = _lastActiveWindow) {
|
||||
return (window->account().maybeSession() == session)
|
||||
&& window->widget()->isActive();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1225,7 +1231,20 @@ void Application::closeChatFromWindows(not_null<PeerData*> peer) {
|
||||
}
|
||||
|
||||
void Application::windowActivated(not_null<Window::Controller*> window) {
|
||||
const auto was = _lastActiveWindow;
|
||||
const auto now = window;
|
||||
_lastActiveWindow = window;
|
||||
|
||||
const auto wasSession = was ? was->account().maybeSession() : nullptr;
|
||||
const auto nowSession = now->account().maybeSession();
|
||||
if (wasSession != nowSession) {
|
||||
if (wasSession) {
|
||||
wasSession->updates().updateOnline();
|
||||
}
|
||||
if (nowSession) {
|
||||
nowSession->updates().updateOnline();
|
||||
}
|
||||
}
|
||||
if (_mediaView && !_mediaView->isHidden()) {
|
||||
_mediaView->activate();
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public:
|
||||
[[nodiscard]] bool exportPreventsQuit();
|
||||
|
||||
// Main::Session component.
|
||||
Main::Session *maybeActiveSession() const;
|
||||
Main::Session *maybePrimarySession() const;
|
||||
[[nodiscard]] int unreadBadge() const;
|
||||
[[nodiscard]] bool unreadBadgeMuted() const;
|
||||
[[nodiscard]] rpl::producer<> unreadBadgeChanges() const;
|
||||
|
@ -718,12 +718,6 @@ void MainWindow::sendPaths() {
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::activeChangedHook() {
|
||||
if (const auto controller = sessionController()) {
|
||||
controller->session().updates().updateOnline();
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() = default;
|
||||
|
||||
namespace App {
|
||||
|
@ -114,7 +114,6 @@ protected:
|
||||
void closeEvent(QCloseEvent *e) override;
|
||||
|
||||
void initHook() override;
|
||||
void activeChangedHook() override;
|
||||
void clearWidgetsHook() override;
|
||||
|
||||
private:
|
||||
|
@ -282,7 +282,7 @@ SystemMediaControlsManager::SystemMediaControlsManager(
|
||||
|
||||
Core::App().passcodeLockValue(
|
||||
) | rpl::filter([=](bool locked) {
|
||||
return locked && Core::App().maybeActiveSession();
|
||||
return locked && Core::App().maybePrimarySession();
|
||||
}) | rpl::start_with_next([=] {
|
||||
_controls->setEnabled(false);
|
||||
}, _lifetime);
|
||||
|
@ -402,7 +402,6 @@ void MainWindow::updateIsActive() {
|
||||
const auto isActive = computeIsActive();
|
||||
if (_isActive != isActive) {
|
||||
_isActive = isActive;
|
||||
activeChangedHook();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,9 +149,6 @@ protected:
|
||||
virtual void initHook() {
|
||||
}
|
||||
|
||||
virtual void activeChangedHook() {
|
||||
}
|
||||
|
||||
virtual void handleVisibleChangedHook(bool visible) {
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,8 @@ void Controller::showAccount(
|
||||
}, _sessionController->lifetime());
|
||||
|
||||
widget()->setInnerFocus();
|
||||
|
||||
session->updates().updateOnline(crl::now());
|
||||
} else {
|
||||
setupIntro();
|
||||
_widget.updateGlobalMenu();
|
||||
|
Loading…
Reference in New Issue
Block a user