Fix global unread notifications #LINQT-2024
This commit is contained in:
parent
453d16250a
commit
4a05b727c6
3 changed files with 16 additions and 0 deletions
|
|
@ -586,6 +586,14 @@ void App::initCore() {
|
||||||
mAccountList->setInitialized(false);
|
mAccountList->setInitialized(false);
|
||||||
mAccountList->lUpdate(true);
|
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());
|
if (!mCallList) setCallList(CallList::create());
|
||||||
else mCallList->lUpdate();
|
else mCallList->lUpdate();
|
||||||
if (!mSettings) {
|
if (!mSettings) {
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,11 @@ void AccountList::setSelf(QSharedPointer<AccountList> me) {
|
||||||
auto model = AccountCore::create(it);
|
auto model = AccountCore::create(it);
|
||||||
if (it == defaultAccount) defaultAccountCore = model;
|
if (it == defaultAccount) defaultAccountCore = model;
|
||||||
accounts->push_back(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]() {
|
mModelConnection->invokeToCore([this, accounts, defaultAccountCore, isInitialization]() {
|
||||||
mustBeInMainThread(getClassName());
|
mustBeInMainThread(getClassName());
|
||||||
|
|
@ -74,6 +79,8 @@ void AccountList::setSelf(QSharedPointer<AccountList> me) {
|
||||||
}
|
}
|
||||||
delete accounts;
|
delete accounts;
|
||||||
});
|
});
|
||||||
|
// Update notification count at startup
|
||||||
|
if (isInitialization) emit unreadNotificationsChanged();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
mModelConnection->makeConnectToModel(
|
mModelConnection->makeConnectToModel(
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ signals:
|
||||||
void haveAccountChanged();
|
void haveAccountChanged();
|
||||||
void defaultAccountChanged();
|
void defaultAccountChanged();
|
||||||
void initializedChanged(bool init);
|
void initializedChanged(bool init);
|
||||||
|
void unreadNotificationsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mHaveAccount = false;
|
bool mHaveAccount = false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue