mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-10 18:23:21 +08:00
fix(count): Fix unread count for badge and tray icon in mac
This commit is contained in:
parent
03cbcd91fe
commit
09c82c76a3
2 changed files with 10 additions and 16 deletions
|
@ -2,15 +2,14 @@ Reflux = require 'reflux'
|
|||
_ = require 'underscore'
|
||||
NylasStore = require 'nylas-store'
|
||||
FocusedPerspectiveStore = require './focused-perspective-store'
|
||||
CategoryStore = require './category-store'
|
||||
ThreadCountsStore = require './thread-counts-store'
|
||||
|
||||
class UnreadBadgeStore extends NylasStore
|
||||
|
||||
constructor: ->
|
||||
@_count = 0
|
||||
@_count = FocusedPerspectiveStore.current().threadUnreadCount()
|
||||
|
||||
@listenTo CategoryStore, @_updateCount
|
||||
@listenTo FocusedPerspectiveStore, @_updateCount
|
||||
@listenTo ThreadCountsStore, @_updateCount
|
||||
NylasEnv.config.observe 'core.notifications.unreadBadge', (val) =>
|
||||
if val is true
|
||||
|
@ -25,18 +24,13 @@ class UnreadBadgeStore extends NylasStore
|
|||
@_count
|
||||
|
||||
_updateCount: =>
|
||||
account = FocusedPerspectiveStore.current().account
|
||||
category = CategoryStore.getStandardCategory(account, 'inbox')
|
||||
if category
|
||||
count = ThreadCountsStore.unreadCountForCategoryId(category.id) ? 0
|
||||
else
|
||||
count = 0
|
||||
|
||||
return if @_count is count
|
||||
|
||||
@_count = count
|
||||
@_setBadgeForCount()
|
||||
@trigger()
|
||||
current = FocusedPerspectiveStore.current()
|
||||
if current.isInbox()
|
||||
count = current.threadUnreadCount()
|
||||
return if @_count is count
|
||||
@_count = count
|
||||
@_setBadgeForCount()
|
||||
@trigger()
|
||||
|
||||
_setBadgeForCount: =>
|
||||
return unless NylasEnv.config.get('core.notifications.unreadBadge')
|
||||
|
|
|
@ -64,7 +64,7 @@ class MailboxPerspective
|
|||
[]
|
||||
|
||||
category: =>
|
||||
return null unless @categories().length isnt 0
|
||||
return null unless @categories().length is 1
|
||||
return @categories()[0]
|
||||
|
||||
threads: =>
|
||||
|
|
Loading…
Reference in a new issue