From 4a05b727c6af260b066457f80967c438c43c6b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20J=C3=B6rgensen?= Date: Fri, 17 Oct 2025 16:36:58 +0200 Subject: [PATCH] Fix global unread notifications #LINQT-2024 --- Linphone/core/App.cpp | 8 ++++++++ Linphone/core/account/AccountList.cpp | 7 +++++++ Linphone/core/account/AccountList.hpp | 1 + 3 files changed, 16 insertions(+) diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index 54db27708..1644ead37 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -586,6 +586,14 @@ void App::initCore() { mAccountList->setInitialized(false); mAccountList->lUpdate(true); } + // Update global unread Notifications when an account updates his unread Notifications + connect(mAccountList.get(), &AccountList::unreadNotificationsChanged, this, [this]() { + lDebug() << "unreadNotificationsChanged of AccountList"; + mCoreModelConnection->invokeToModel([this] { + int n = mEventCountNotifier->getCurrentEventCount(); + mCoreModelConnection->invokeToCore([this, n] { mEventCountNotifier->notifyEventCount(n); }); + }); + }); if (!mCallList) setCallList(CallList::create()); else mCallList->lUpdate(); if (!mSettings) { diff --git a/Linphone/core/account/AccountList.cpp b/Linphone/core/account/AccountList.cpp index 4b930e2b6..ce3cf4afa 100644 --- a/Linphone/core/account/AccountList.cpp +++ b/Linphone/core/account/AccountList.cpp @@ -61,6 +61,11 @@ void AccountList::setSelf(QSharedPointer me) { auto model = AccountCore::create(it); if (it == defaultAccount) defaultAccountCore = model; accounts->push_back(model); + connect(model.get(), &AccountCore::unreadNotificationsChanged, this, + [this] { emit unreadNotificationsChanged(); }); + connect(model.get(), &AccountCore::removed, this, [this, model]() { + disconnect(model.get(), &AccountCore::unreadNotificationsChanged, this, nullptr); + }); } mModelConnection->invokeToCore([this, accounts, defaultAccountCore, isInitialization]() { mustBeInMainThread(getClassName()); @@ -74,6 +79,8 @@ void AccountList::setSelf(QSharedPointer me) { } delete accounts; }); + // Update notification count at startup + if (isInitialization) emit unreadNotificationsChanged(); }); }); mModelConnection->makeConnectToModel( diff --git a/Linphone/core/account/AccountList.hpp b/Linphone/core/account/AccountList.hpp index 0b0f3068c..c0eb0f520 100644 --- a/Linphone/core/account/AccountList.hpp +++ b/Linphone/core/account/AccountList.hpp @@ -58,6 +58,7 @@ signals: void haveAccountChanged(); void defaultAccountChanged(); void initializedChanged(bool init); + void unreadNotificationsChanged(); private: bool mHaveAccount = false;