refs #769 Switch direct streaming method

This commit is contained in:
AkiraFukushima 2018-12-18 23:23:12 +09:00
parent 1d30a5e32c
commit 13eaa22832
2 changed files with 9 additions and 5 deletions

View File

@ -432,20 +432,21 @@ ipcMain.on('stop-user-streaming', (event, _) => {
let directMessagesStreaming = null
ipcMain.on('start-directmessages-streaming', (event, ac) => {
accountManager.getAccount(ac._id)
ipcMain.on('start-directmessages-streaming', (event, obj) => {
const { account, useWebsocket } = obj
accountManager.getAccount(account._id)
.catch((err) => {
log.error(err)
event.sender.send('error-start-directmessages-streaming', err)
})
.then((account) => {
.then((acct) => {
// Stop old directmessages streaming
if (directMessagesStreaming !== null) {
directMessagesStreaming.stop()
directMessagesStreaming = null
}
directMessagesStreaming = new StreamingManager(account)
directMessagesStreaming = new StreamingManager(acct, useWebsocket)
directMessagesStreaming.start(
'direct',
'',

View File

@ -316,7 +316,10 @@ const TimelineSpace = {
},
startDirectMessagesStreaming ({ state }) {
return new Promise((resolve, reject) => {
ipcRenderer.send('start-directmessages-streaming', state.account)
ipcRenderer.send('start-directmessages-streaming', {
account: state.account,
useWebsocket: state.useWebsocket
})
ipcRenderer.once('error-start-directmessages-streaming', (event, err) => {
reject(err)
})