refs #6 Stop userstreaming when timeline space will destroy

This commit is contained in:
AkiraFukushima 2018-03-12 16:47:27 +09:00
parent 41900126cd
commit 9b0728b724
3 changed files with 16 additions and 2 deletions

View File

@ -128,6 +128,8 @@ ipcMain.on('get-local-account', (event, id) => {
})
// streaming
let userStreaming = null
ipcMain.on('start-user-streaming', (event, ac) => {
const account = new Account(db)
account.getAccount(ac._id)
@ -135,8 +137,8 @@ ipcMain.on('start-user-streaming', (event, ac) => {
event.sender.send('error-start-user-streaming', err)
})
.then((account) => {
const streaming = new Streaming(account)
streaming.startUserStreaming(
userStreaming = new Streaming(account)
userStreaming.startUserStreaming(
(update) => {
event.sender.send('update-start-user-streaming', update)
},
@ -149,6 +151,12 @@ ipcMain.on('start-user-streaming', (event, ac) => {
)
})
})
ipcMain.on('stop-user-streaming', (event, _) => {
userStreaming.stop()
userStreaming = null
})
/**
* Auto Updater
*

View File

@ -25,6 +25,9 @@ export default {
type: 'error'
})
})
},
beforeDestroy () {
this.$store.dispatch('TimelineSpace/stopUserStreaming')
}
}
</script>

View File

@ -72,6 +72,9 @@ const TimelineSpace = {
ipcRenderer.on('notification-start-user-streaming', (event, notification) => {
commit('appendNotification', notification)
})
},
stopUserStreaming ({ commit }) {
ipcRenderer.send('stop-user-streaming')
}
}
}