mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show current chat name in the window title.
This commit is contained in:
parent
173108a9cb
commit
fc26457218
12 changed files with 100 additions and 76 deletions
|
@ -229,12 +229,22 @@ void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::unreadCounterChangedHook() {
|
void MainWindow::unreadCounterChangedHook() {
|
||||||
updateIconCounters();
|
updateUnityCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateIconCounters() {
|
void MainWindow::updateWindowIcon() {
|
||||||
updateWindowIcon();
|
const auto session = sessionController()
|
||||||
|
? &sessionController()->session()
|
||||||
|
: nullptr;
|
||||||
|
const auto supportIcon = session && session->supportMode();
|
||||||
|
if (supportIcon != _usingSupportIcon || _icon.isNull()) {
|
||||||
|
_icon = Window::CreateIcon(session);
|
||||||
|
_usingSupportIcon = supportIcon;
|
||||||
|
}
|
||||||
|
setWindowIcon(_icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateUnityCounter() {
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
const auto launcherUrl = Glib::ustring(
|
const auto launcherUrl = Glib::ustring(
|
||||||
"application://"
|
"application://"
|
||||||
|
|
|
@ -21,9 +21,10 @@ namespace Platform {
|
||||||
class MainWindow : public Window::MainWindow {
|
class MainWindow : public Window::MainWindow {
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(not_null<Window::Controller*> controller);
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
|
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
void updateWindowIcon() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *evt) override;
|
bool eventFilter(QObject *obj, QEvent *evt) override;
|
||||||
|
|
||||||
|
@ -35,6 +36,9 @@ protected:
|
||||||
void createGlobalMenu() override;
|
void createGlobalMenu() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateUnityCounter();
|
||||||
|
void handleNativeSurfaceChanged(bool exist);
|
||||||
|
|
||||||
QMenuBar *psMainMenu = nullptr;
|
QMenuBar *psMainMenu = nullptr;
|
||||||
QAction *psLogout = nullptr;
|
QAction *psLogout = nullptr;
|
||||||
QAction *psUndo = nullptr;
|
QAction *psUndo = nullptr;
|
||||||
|
@ -56,8 +60,8 @@ private:
|
||||||
QAction *psMonospace = nullptr;
|
QAction *psMonospace = nullptr;
|
||||||
QAction *psClearFormat = nullptr;
|
QAction *psClearFormat = nullptr;
|
||||||
|
|
||||||
void updateIconCounters();
|
QIcon _icon;
|
||||||
void handleNativeSurfaceChanged(bool exist);
|
bool _usingSupportIcon = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ private:
|
||||||
friend class Private;
|
friend class Private;
|
||||||
|
|
||||||
void hideAndDeactivate();
|
void hideAndDeactivate();
|
||||||
void updateIconCounters();
|
void updateDockCounter();
|
||||||
|
|
||||||
std::unique_ptr<Private> _private;
|
std::unique_ptr<Private> _private;
|
||||||
|
|
||||||
|
|
|
@ -270,10 +270,10 @@ bool MainWindow::preventsQuit(Core::QuitReason reason) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::unreadCounterChangedHook() {
|
void MainWindow::unreadCounterChangedHook() {
|
||||||
updateIconCounters();
|
updateDockCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateIconCounters() {
|
void MainWindow::updateDockCounter() {
|
||||||
const auto counter = Core::App().unreadBadge();
|
const auto counter = Core::App().unreadBadge();
|
||||||
|
|
||||||
const auto string = !counter
|
const auto string = !counter
|
||||||
|
|
|
@ -228,16 +228,19 @@ int32 MainWindow::screenNameChecksum(const QString &name) const {
|
||||||
|
|
||||||
void MainWindow::forceIconRefresh() {
|
void MainWindow::forceIconRefresh() {
|
||||||
const auto refresher = std::make_unique<QWidget>(this);
|
const auto refresher = std::make_unique<QWidget>(this);
|
||||||
refresher->setWindowFlags(static_cast<Qt::WindowFlags>(Qt::Tool) | Qt::FramelessWindowHint);
|
refresher->setWindowFlags(
|
||||||
|
static_cast<Qt::WindowFlags>(Qt::Tool) | Qt::FramelessWindowHint);
|
||||||
refresher->setGeometry(x() + 1, y() + 1, 1, 1);
|
refresher->setGeometry(x() + 1, y() + 1, 1, 1);
|
||||||
auto palette = refresher->palette();
|
auto palette = refresher->palette();
|
||||||
palette.setColor(QPalette::Window, (isActiveWindow() ? st::titleBgActive : st::titleBg)->c);
|
palette.setColor(
|
||||||
|
QPalette::Window,
|
||||||
|
(isActiveWindow() ? st::titleBgActive : st::titleBg)->c);
|
||||||
refresher->setPalette(palette);
|
refresher->setPalette(palette);
|
||||||
refresher->show();
|
refresher->show();
|
||||||
refresher->raise();
|
refresher->raise();
|
||||||
refresher->activateWindow();
|
refresher->activateWindow();
|
||||||
|
|
||||||
updateIconCounters();
|
updateTaskbarAndIconCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) {
|
void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) {
|
||||||
|
@ -309,7 +312,7 @@ QRect MainWindow::computeDesktopRect() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateWindowIcon() {
|
void MainWindow::updateWindowIcon() {
|
||||||
updateIconCounters();
|
updateTaskbarAndIconCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::isActiveForTrayMenu() {
|
bool MainWindow::isActiveForTrayMenu() {
|
||||||
|
@ -318,10 +321,10 @@ bool MainWindow::isActiveForTrayMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::unreadCounterChangedHook() {
|
void MainWindow::unreadCounterChangedHook() {
|
||||||
updateIconCounters();
|
updateTaskbarAndIconCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateIconCounters() {
|
void MainWindow::updateTaskbarAndIconCounters() {
|
||||||
const auto counter = Core::App().unreadBadge();
|
const auto counter = Core::App().unreadBadge();
|
||||||
const auto muted = Core::App().unreadBadgeMuted();
|
const auto muted = Core::App().unreadBadgeMuted();
|
||||||
const auto controller = sessionController();
|
const auto controller = sessionController();
|
||||||
|
|
|
@ -51,7 +51,7 @@ private:
|
||||||
struct Private;
|
struct Private;
|
||||||
|
|
||||||
void setupNativeWindowFrame();
|
void setupNativeWindowFrame();
|
||||||
void updateIconCounters();
|
void updateTaskbarAndIconCounters();
|
||||||
void validateWindowTheme(bool native, bool night);
|
void validateWindowTheme(bool native, bool night);
|
||||||
|
|
||||||
void forceIconRefresh();
|
void forceIconRefresh();
|
||||||
|
|
|
@ -139,7 +139,6 @@ void SetupExperimental(
|
||||||
addToggle(ChatHelpers::kOptionTabbedPanelShowOnClick);
|
addToggle(ChatHelpers::kOptionTabbedPanelShowOnClick);
|
||||||
addToggle(Window::kOptionViewProfileInChatsListContextMenu);
|
addToggle(Window::kOptionViewProfileInChatsListContextMenu);
|
||||||
addToggle(Dialogs::kOptionCtrlClickChatNewWindow);
|
addToggle(Dialogs::kOptionCtrlClickChatNewWindow);
|
||||||
addToggle(Window::kOptionShowChatNameInNewWindow);
|
|
||||||
addToggle(Ui::GL::kOptionAllowLinuxNvidiaOpenGL);
|
addToggle(Ui::GL::kOptionAllowLinuxNvidiaOpenGL);
|
||||||
addToggle(Ui::kOptionUseSmallMsgBubbleRadius);
|
addToggle(Ui::kOptionUseSmallMsgBubbleRadius);
|
||||||
addToggle(Media::Player::kOptionDisableAutoplayNext);
|
addToggle(Media::Player::kOptionDisableAutoplayNext);
|
||||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/sandbox.h"
|
#include "core/sandbox.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_forum_topic.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "main/main_session_settings.h"
|
#include "main/main_session_settings.h"
|
||||||
#include "base/options.h"
|
#include "base/options.h"
|
||||||
|
@ -49,16 +50,8 @@ namespace {
|
||||||
|
|
||||||
constexpr auto kSaveWindowPositionTimeout = crl::time(1000);
|
constexpr auto kSaveWindowPositionTimeout = crl::time(1000);
|
||||||
|
|
||||||
base::options::toggle ShowChatNameInNewWindow({
|
|
||||||
.id = kOptionShowChatNameInNewWindow,
|
|
||||||
.name = "Chat name in window title",
|
|
||||||
.description = "Show chat name in the additional windows titles.",
|
|
||||||
});
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
const char kOptionShowChatNameInNewWindow[] = "show-chat-name-in-new-window";
|
|
||||||
|
|
||||||
const QImage &Logo() {
|
const QImage &Logo() {
|
||||||
static const auto result = QImage(u":/gui/art/logo_256.png"_q);
|
static const auto result = QImage(u":/gui/art/logo_256.png"_q);
|
||||||
return result;
|
return result;
|
||||||
|
@ -329,7 +322,9 @@ MainWindow::MainWindow(not_null<Controller*> controller)
|
||||||
|
|
||||||
Core::App().unreadBadgeChanges(
|
Core::App().unreadBadgeChanges(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
updateUnreadCounter();
|
updateTitle();
|
||||||
|
unreadCounterChangedHook();
|
||||||
|
Core::App().tray().updateIconCounters();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
Core::App().settings().workModeChanges(
|
Core::App().settings().workModeChanges(
|
||||||
|
@ -421,18 +416,6 @@ bool MainWindow::computeIsActive() const {
|
||||||
return isActiveWindow() && isVisible() && !(windowState() & Qt::WindowMinimized);
|
return isActiveWindow() && isVisible() && !(windowState() & Qt::WindowMinimized);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateWindowIcon() {
|
|
||||||
const auto session = sessionController()
|
|
||||||
? &sessionController()->session()
|
|
||||||
: nullptr;
|
|
||||||
const auto supportIcon = session && session->supportMode();
|
|
||||||
if (supportIcon != _usingSupportIcon || _icon.isNull()) {
|
|
||||||
_icon = CreateIcon(session);
|
|
||||||
_usingSupportIcon = supportIcon;
|
|
||||||
}
|
|
||||||
setWindowIcon(_icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect MainWindow::desktopRect() const {
|
QRect MainWindow::desktopRect() const {
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
if (!_monitorLastGot || now >= _monitorLastGot + crl::time(1000)) {
|
if (!_monitorLastGot || now >= _monitorLastGot + crl::time(1000)) {
|
||||||
|
@ -446,7 +429,6 @@ void MainWindow::init() {
|
||||||
createWinId();
|
createWinId();
|
||||||
|
|
||||||
initHook();
|
initHook();
|
||||||
updateWindowIcon();
|
|
||||||
|
|
||||||
// Non-queued activeChanged handlers must use QtSignalProducer.
|
// Non-queued activeChanged handlers must use QtSignalProducer.
|
||||||
connect(
|
connect(
|
||||||
|
@ -478,7 +460,8 @@ void MainWindow::init() {
|
||||||
refreshTitleWidget();
|
refreshTitleWidget();
|
||||||
|
|
||||||
initGeometry();
|
initGeometry();
|
||||||
updateUnreadCounter();
|
updateTitle();
|
||||||
|
updateWindowIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::handleStateChanged(Qt::WindowState state) {
|
void MainWindow::handleStateChanged(Qt::WindowState state) {
|
||||||
|
@ -522,7 +505,8 @@ void MainWindow::showFromTray() {
|
||||||
updateGlobalMenu();
|
updateGlobalMenu();
|
||||||
});
|
});
|
||||||
activate();
|
activate();
|
||||||
updateUnreadCounter();
|
unreadCounterChangedHook();
|
||||||
|
Core::App().tray().updateIconCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::quitFromTray() {
|
void MainWindow::quitFromTray() {
|
||||||
|
@ -801,30 +785,34 @@ void MainWindow::updateControlsGeometry() {
|
||||||
_body->setGeometry(bodyLeft, bodyTop, bodyWidth, inner.height() - (bodyTop - inner.y()));
|
_body->setGeometry(bodyLeft, bodyTop, bodyWidth, inner.height() - (bodyTop - inner.y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateUnreadCounter() {
|
void MainWindow::updateTitle() {
|
||||||
if (Core::Quitting()) {
|
if (Core::Quitting()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShowChatNameInNewWindow.value() && singlePeer()) {
|
const auto counter = Core::App().unreadBadge();
|
||||||
const auto peer = singlePeer();
|
const auto basic = (counter > 0)
|
||||||
const auto history = peer->owner().history(peer);
|
? u"Telegram (%1)"_q.arg(counter)
|
||||||
const auto name = peer->isSelf()
|
: u"Telegram"_q;
|
||||||
? tr::lng_saved_messages(tr::now)
|
const auto session = _controller->sessionController();
|
||||||
: peer->name();
|
const auto key = session ? session->activeChatCurrent() : Dialogs::Key();
|
||||||
const auto counter = history->unreadCount();
|
const auto thread = key ? key.thread() : nullptr;
|
||||||
setTitle((counter > 0)
|
if (!thread) {
|
||||||
? u"(%1) %2 \u2013 Telegram"_q.arg(QString::number(counter), name)
|
setTitle(basic);
|
||||||
: u"%1 \u2013 Telegram"_q.arg(name));
|
return;
|
||||||
} else {
|
|
||||||
const auto counter = Core::App().unreadBadge();
|
|
||||||
setTitle((counter > 0)
|
|
||||||
? u"Telegram (%1)"_q.arg(counter)
|
|
||||||
: u"Telegram"_q);
|
|
||||||
}
|
}
|
||||||
|
const auto history = thread->owningHistory();
|
||||||
Core::App().tray().updateIconCounters();
|
const auto topic = thread->asTopic();
|
||||||
unreadCounterChangedHook();
|
const auto name = topic
|
||||||
|
? topic->title()
|
||||||
|
: history->peer->isSelf()
|
||||||
|
? tr::lng_saved_messages(tr::now)
|
||||||
|
: history->peer->name();
|
||||||
|
const auto threadCounter = thread->chatListBadgesState().unreadCounter;
|
||||||
|
const auto primary = (threadCounter > 0)
|
||||||
|
? u"(%1) %2"_q.arg(threadCounter).arg(name)
|
||||||
|
: name;
|
||||||
|
setTitle(primary + u" \u2013 "_q + basic);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect MainWindow::computeDesktopRect() const {
|
QRect MainWindow::computeDesktopRect() const {
|
||||||
|
|
|
@ -55,8 +55,6 @@ struct CounterLayerArgs {
|
||||||
[[nodiscard]] QImage GenerateCounterLayer(CounterLayerArgs &&args);
|
[[nodiscard]] QImage GenerateCounterLayer(CounterLayerArgs &&args);
|
||||||
[[nodiscard]] QImage WithSmallCounter(QImage image, CounterLayerArgs &&args);
|
[[nodiscard]] QImage WithSmallCounter(QImage image, CounterLayerArgs &&args);
|
||||||
|
|
||||||
extern const char kOptionShowChatNameInNewWindow[];
|
|
||||||
|
|
||||||
class MainWindow : public Ui::RpWindow {
|
class MainWindow : public Ui::RpWindow {
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(not_null<Controller*> controller);
|
explicit MainWindow(not_null<Controller*> controller);
|
||||||
|
@ -121,7 +119,8 @@ public:
|
||||||
|
|
||||||
rpl::producer<> leaveEvents() const;
|
rpl::producer<> leaveEvents() const;
|
||||||
|
|
||||||
virtual void updateWindowIcon();
|
virtual void updateWindowIcon() = 0;
|
||||||
|
void updateTitle();
|
||||||
|
|
||||||
void clearWidgets();
|
void clearWidgets();
|
||||||
|
|
||||||
|
@ -184,7 +183,6 @@ protected:
|
||||||
virtual int32 screenNameChecksum(const QString &name) const;
|
virtual int32 screenNameChecksum(const QString &name) const;
|
||||||
|
|
||||||
void setPositionInited();
|
void setPositionInited();
|
||||||
void updateUnreadCounter();
|
|
||||||
|
|
||||||
virtual QRect computeDesktopRect() const;
|
virtual QRect computeDesktopRect() const;
|
||||||
|
|
||||||
|
@ -209,9 +207,6 @@ private:
|
||||||
object_ptr<Ui::RpWidget> _body;
|
object_ptr<Ui::RpWidget> _body;
|
||||||
object_ptr<TWidget> _rightColumn = { nullptr };
|
object_ptr<TWidget> _rightColumn = { nullptr };
|
||||||
|
|
||||||
QIcon _icon;
|
|
||||||
bool _usingSupportIcon = false;
|
|
||||||
|
|
||||||
bool _isActive = false;
|
bool _isActive = false;
|
||||||
|
|
||||||
rpl::event_stream<> _leaveEvents;
|
rpl::event_stream<> _leaveEvents;
|
||||||
|
|
|
@ -62,6 +62,9 @@ Controller::~Controller() {
|
||||||
// We want to delete all widgets before the _sessionController.
|
// We want to delete all widgets before the _sessionController.
|
||||||
_widget.ui_hideSettingsAndLayer(anim::type::instant);
|
_widget.ui_hideSettingsAndLayer(anim::type::instant);
|
||||||
_widget.clearWidgets();
|
_widget.clearWidgets();
|
||||||
|
_accountLifetime.destroy();
|
||||||
|
_sessionControllerValue = nullptr;
|
||||||
|
_sessionController = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::showAccount(not_null<Main::Account*> account) {
|
void Controller::showAccount(not_null<Main::Account*> account) {
|
||||||
|
@ -103,6 +106,8 @@ void Controller::showAccount(
|
||||||
_sessionController = session
|
_sessionController = session
|
||||||
? std::make_unique<SessionController>(session, this)
|
? std::make_unique<SessionController>(session, this)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
_sessionControllerValue = _sessionController.get();
|
||||||
|
|
||||||
auto oldContentCache = _widget.grabForSlideAnimation();
|
auto oldContentCache = _widget.grabForSlideAnimation();
|
||||||
_widget.updateWindowIcon();
|
_widget.updateWindowIcon();
|
||||||
if (session) {
|
if (session) {
|
||||||
|
@ -124,6 +129,14 @@ void Controller::showAccount(
|
||||||
|
|
||||||
widget()->setInnerFocus();
|
widget()->setInnerFocus();
|
||||||
|
|
||||||
|
_sessionController->activeChatChanges(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
_widget.updateTitle();
|
||||||
|
}, _sessionController->lifetime());
|
||||||
|
if (_sessionController->activeChatCurrent().thread()) {
|
||||||
|
_widget.updateTitle();
|
||||||
|
}
|
||||||
|
|
||||||
session->updates().updateOnline(crl::now());
|
session->updates().updateOnline(crl::now());
|
||||||
} else {
|
} else {
|
||||||
sideBarChanged();
|
sideBarChanged();
|
||||||
|
@ -254,6 +267,16 @@ Main::Session *Controller::maybeSession() const {
|
||||||
return _account ? _account->maybeSession() : nullptr;
|
return _account ? _account->maybeSession() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto Controller::sessionControllerValue() const
|
||||||
|
-> rpl::producer<SessionController*> {
|
||||||
|
return _sessionControllerValue.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Controller::sessionControllerChanges() const
|
||||||
|
-> rpl::producer<SessionController*> {
|
||||||
|
return _sessionControllerValue.changes();
|
||||||
|
}
|
||||||
|
|
||||||
bool Controller::locked() const {
|
bool Controller::locked() const {
|
||||||
if (Core::App().passcodeLocked()) {
|
if (Core::App().passcodeLocked()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -54,6 +54,10 @@ public:
|
||||||
[[nodiscard]] SessionController *sessionController() const {
|
[[nodiscard]] SessionController *sessionController() const {
|
||||||
return _sessionController.get();
|
return _sessionController.get();
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] auto sessionControllerValue() const
|
||||||
|
-> rpl::producer<SessionController*>;
|
||||||
|
[[nodiscard]] auto sessionControllerChanges() const
|
||||||
|
-> rpl::producer<SessionController*>;
|
||||||
[[nodiscard]] bool locked() const;
|
[[nodiscard]] bool locked() const;
|
||||||
|
|
||||||
[[nodiscard]] Adaptive &adaptive() const;
|
[[nodiscard]] Adaptive &adaptive() const;
|
||||||
|
@ -144,6 +148,7 @@ private:
|
||||||
::MainWindow _widget;
|
::MainWindow _widget;
|
||||||
const std::unique_ptr<Adaptive> _adaptive;
|
const std::unique_ptr<Adaptive> _adaptive;
|
||||||
std::unique_ptr<SessionController> _sessionController;
|
std::unique_ptr<SessionController> _sessionController;
|
||||||
|
rpl::variable<SessionController*> _sessionControllerValue;
|
||||||
QPointer<Ui::BoxContent> _termsBox;
|
QPointer<Ui::BoxContent> _termsBox;
|
||||||
|
|
||||||
rpl::event_stream<Media::View::OpenRequest> _openInMediaViewRequests;
|
rpl::event_stream<Media::View::OpenRequest> _openInMediaViewRequests;
|
||||||
|
|
|
@ -943,25 +943,22 @@ void MainMenu::initResetScaleButton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
OthersUnreadState OtherAccountsUnreadStateCurrent() {
|
OthersUnreadState OtherAccountsUnreadStateCurrent() {
|
||||||
auto &app = Core::App();
|
auto &domain = Core::App().domain();
|
||||||
const auto active = &app.activeAccount();
|
const auto active = &domain.active();
|
||||||
|
auto counter = 0;
|
||||||
auto allMuted = true;
|
auto allMuted = true;
|
||||||
for (const auto &[index, account] : app.domain().accounts()) {
|
for (const auto &[index, account] : domain.accounts()) {
|
||||||
if (account.get() == active) {
|
if (account.get() == active) {
|
||||||
continue;
|
continue;
|
||||||
} else if (const auto session = account->maybeSession()) {
|
} else if (const auto session = account->maybeSession()) {
|
||||||
|
counter += session->data().unreadBadge();
|
||||||
if (!session->data().unreadBadgeMuted()) {
|
if (!session->data().unreadBadgeMuted()) {
|
||||||
allMuted = false;
|
allMuted = false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// In case we are logging out in the last paint for the slide animation
|
|
||||||
// the account doesn't have the session here already.
|
|
||||||
const auto current = active->maybeSession();
|
|
||||||
return {
|
return {
|
||||||
.count = (app.unreadBadge()
|
.count = counter,
|
||||||
- (current ? current->data().unreadBadge() : 0)),
|
|
||||||
.allMuted = allMuted,
|
.allMuted = allMuted,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue