Skip to content

Commit

Permalink
refs #662 Add background streaming for direct message
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Nov 3, 2018
1 parent b1efcda commit 11f65b6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/main/index.js
Expand Up @@ -421,6 +421,43 @@ ipcMain.on('stop-user-streaming', (event, _) => {
}
})

let directMessageStreaming = null

ipcMain.on('start-directmessage-streaming', (event, ac) => {
accountManager.getAccount(ac._id)
.catch((err) => {
log.error(err)
event.sender.send('error-start-directmessage-streaming', err)
})
.then((account) => {
// Stop old directmessage streaming
if (directMessageStreaming !== null) {
directMessageStreaming.stop()
directMessageStreaming = null
}

directMessageStreaming = new StreamingManager(account)
directMessageStreaming.start(
'direct',
null,
(update) => {
event.sender.send('update-start-directmessage-streaming', update)
},
(err) => {
log.error(err)
event.sender.send('error-start-directmessage-streaming', err)
}
)
})
})

ipcMain.on('stop-directmessage-streaming', (event, _) => {
if (directMessageStreaming !== null) {
directMessageStreaming.stop()
directMessageStreaming = null
}
})

let localStreaming = null

ipcMain.on('start-local-streaming', (event, ac) => {
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/components/TimelineSpace.vue
Expand Up @@ -74,6 +74,8 @@ export default {
window.removeEventListener('drop', this.handleDrop)
this.$store.dispatch('TimelineSpace/stopUserStreaming')
this.$store.dispatch('TimelineSpace/unbindUserStreaming')
this.$store.dispatch('TimelineSpace/stopDirectMessageStreaming')
this.$store.dispatch('TimelineSpace/unbindDirectMessageStreaming')
this.$store.dispatch('TimelineSpace/stopLocalStreaming')
this.$store.dispatch('TimelineSpace/unbindLocalStreaming')
},
Expand Down

0 comments on commit 11f65b6

Please sign in to comment.