Merge pull request #394 from h3poteto/iss-393

closes #393 Show icon badge when receive notifications
This commit is contained in:
AkiraFukushima 2018-06-14 23:00:06 +09:00 committed by GitHub
commit 99aa6fe1b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -395,6 +395,13 @@ ipcMain.on('remove-all-accounts', (event, _) => {
})
})
// badge
ipcMain.on('reset-badge', () => {
if (process.platform === 'darwin') {
app.dock.setBadge('')
}
})
// streaming
let userStreaming = null
@ -419,6 +426,9 @@ ipcMain.on('start-user-streaming', (event, ac) => {
},
(notification) => {
event.sender.send('notification-start-user-streaming', notification)
if (process.platform === 'darwin') {
app.dock.setBadge('•')
}
},
(err) => {
log.error(err)

View File

@ -29,6 +29,7 @@ export default {
},
mounted () {
this.$store.commit('TimelineSpace/SideMenu/changeUnreadNotifications', false)
this.$store.dispatch('TimelineSpace/Contents/Notifications/resetBadge')
document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
},
beforeUpdate () {

View File

@ -1,3 +1,4 @@
import { ipcRenderer } from 'electron'
import Mastodon from 'megalodon'
const Notifications = {
@ -87,6 +88,9 @@ const Notifications = {
commit('changeLazyLoading', false)
throw err
})
},
resetBadge () {
ipcRenderer.send('reset-badge')
}
}
}