mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-19 05:31:22 +00:00
Improve badges in accounts list.
This commit is contained in:
parent
7b0a32b607
commit
c92c15883d
@ -244,7 +244,7 @@ void MainMenu::AccountButton::paintEvent(QPaintEvent *e) {
|
|||||||
paintUserpic(p);
|
paintUserpic(p);
|
||||||
|
|
||||||
auto available = width() - _st.itemPadding.left();
|
auto available = width() - _st.itemPadding.left();
|
||||||
if (_unreadBadge) {
|
if (_unreadBadge && _account != &Core::App().activeAccount()) {
|
||||||
_unreadSt.muted = _unreadBadgeMuted;
|
_unreadSt.muted = _unreadBadgeMuted;
|
||||||
const auto string = (_unreadBadge > 99)
|
const auto string = (_unreadBadge > 99)
|
||||||
? "99+"
|
? "99+"
|
||||||
@ -402,20 +402,23 @@ void MainMenu::ToggleAccountsButton::validateUnreadBadge() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString MainMenu::ToggleAccountsButton::computeUnreadBadge() const {
|
QString MainMenu::ToggleAccountsButton::computeUnreadBadge() const {
|
||||||
auto count = 0;
|
|
||||||
const auto active = &Core::App().activeAccount();
|
const auto active = &Core::App().activeAccount();
|
||||||
const auto countMessages = Core::App().settings().countUnreadMessages();
|
auto allMuted = true;
|
||||||
for (const auto &[index, account] : Core::App().domain().accounts()) {
|
for (const auto &[index, account] : Core::App().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()) {
|
||||||
const auto state = account->session().data().chatsList()->unreadState();
|
if (!session->data().unreadBadgeMuted()) {
|
||||||
count += std::max(state.marks - state.marksMuted, 0)
|
allMuted = false;
|
||||||
+ (countMessages
|
break;
|
||||||
? std::max(state.messages - state.messagesMuted, 0)
|
}
|
||||||
: std::max(state.chats - state.chatsMuted, 0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (allMuted) {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
const auto count = Core::App().unreadBadge()
|
||||||
|
- active->session().data().unreadBadge();
|
||||||
return (count > 99)
|
return (count > 99)
|
||||||
? u"99+"_q
|
? u"99+"_q
|
||||||
: (count > 0)
|
: (count > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user