Fix global unread notifications #LINQT-2024

This commit is contained in:
Alexandre Jörgensen 2025-10-17 16:36:58 +02:00
parent 453d16250a
commit 4a05b727c6
3 changed files with 16 additions and 0 deletions

View file

@ -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) {

View file

@ -61,6 +61,11 @@ void AccountList::setSelf(QSharedPointer<AccountList> 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<AccountList> me) {
}
delete accounts;
});
// Update notification count at startup
if (isInitialization) emit unreadNotificationsChanged();
});
});
mModelConnection->makeConnectToModel(

View file

@ -58,6 +58,7 @@ signals:
void haveAccountChanged();
void defaultAccountChanged();
void initializedChanged(bool init);
void unreadNotificationsChanged();
private:
bool mHaveAccount = false;