Skip to content

Commit

Permalink
feat: update tray icon based on changes in the download status
Browse files Browse the repository at this point in the history
  • Loading branch information
agalwood committed Mar 22, 2019
1 parent e970a51 commit e014580
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,9 @@ export default class Application extends EventEmitter {
ipcMain.on('update-menu-states', (event, visibleStates, enabledStates, checkedStates) => {
this.menuManager.updateStates(visibleStates, enabledStates, checkedStates)
})

ipcMain.on('download-status-change', (event, status) => {
this.trayManager.updateStatus(status)
})
}
}
2 changes: 1 addition & 1 deletion src/main/ui/TrayManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class TrayManager extends EventEmitter {
}

updateStatus (status) {
const icon = status === 'active' ? this.activeIcon : this.normalIcon
const icon = status ? this.activeIcon : this.normalIcon
tray.setImage(icon)
}
}
18 changes: 17 additions & 1 deletion src/renderer/components/Native/EngineClient.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
</template>

<script>
import is from 'electron-is'
import { mapState } from 'vuex'
import api from '@/api'
import {
Expand All @@ -18,10 +19,17 @@
export default {
name: 'mo-engine-client',
data: function () {
return {
downloading: false
}
},
computed: {
isRenderer: () => is.renderer(),
...mapState('app', {
downloadSpeed: state => state.stat.downloadSpeed,
interval: state => state.interval
interval: state => state.interval,
numActive: state => state.stat.numActive
}),
...mapState('task', {
taskItemInfoVisible: state => state.taskItemInfoVisible,
Expand All @@ -34,6 +42,14 @@
watch: {
downloadSpeed: function (val, oldVal) {
showDownloadSpeedInDock(val)
},
numActive: function (val, oldVal) {
this.downloading = val > 0
},
downloading: function (val, oldVal) {
if (val !== oldVal && this.isRenderer) {
this.$electron.ipcRenderer.send('download-status-change', val)
}
}
},
methods: {
Expand Down

0 comments on commit e014580

Please sign in to comment.