mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
fix(badge): Add option for total count
This commit is contained in:
parent
2f7d64b27a
commit
58e1ed57ee
2 changed files with 14 additions and 11 deletions
|
@ -96,8 +96,9 @@ module.exports =
|
|||
type: 'boolean'
|
||||
default: true
|
||||
title: "Play sound when receiving new mail"
|
||||
unreadBadge:
|
||||
type: 'boolean'
|
||||
default: true
|
||||
countBadge:
|
||||
type: 'string'
|
||||
default: 'unread'
|
||||
enum: ['hide', 'unread', 'total']
|
||||
enumLabels: ['Hide Badge', 'Show Unread Count', 'Show Total Count']
|
||||
title: "Show badge on the app icon"
|
||||
platforms: ['darwin']
|
||||
|
|
|
@ -12,9 +12,9 @@ class BadgeStore extends NylasStore {
|
|||
this.listenTo(FocusedPerspectiveStore, this._updateCounts);
|
||||
this.listenTo(ThreadCountsStore, this._updateCounts);
|
||||
|
||||
NylasEnv.config.onDidChange('core.notifications.unreadBadge', ({newValue}) => {
|
||||
if (newValue === true) {
|
||||
this._setBadgeForCount()
|
||||
NylasEnv.config.onDidChange('core.notifications.countBadge', ({newValue}) => {
|
||||
if (newValue !== 'hide') {
|
||||
this._setBadgeForCount();
|
||||
} else {
|
||||
this._setBadge("");
|
||||
}
|
||||
|
@ -52,17 +52,19 @@ class BadgeStore extends NylasStore {
|
|||
}
|
||||
|
||||
_setBadgeForCount = () => {
|
||||
if (!NylasEnv.config.get('core.notifications.unreadBadge')) {
|
||||
const badgePref = NylasEnv.config.get('core.notifications.countBadge');
|
||||
if (!badgePref || badgePref === 'hide') {
|
||||
return;
|
||||
}
|
||||
if (!NylasEnv.isMainWindow() && !NylasEnv.inSpecMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._unread > 999) {
|
||||
const count = badgePref === 'unread' ? this._unread : this._total;
|
||||
if (count > 999) {
|
||||
this._setBadge("999+");
|
||||
} else if (this._unread > 0) {
|
||||
this._setBadge(`${this._unread}`);
|
||||
} else if (count > 0) {
|
||||
this._setBadge(`${count}`);
|
||||
} else {
|
||||
this._setBadge("");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue