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 let directMessagesStreaming = null
ipcMain.on('start-directmessages-streaming', (event, ac) => { ipcMain.on('start-directmessages-streaming', (event, obj) => {
accountManager.getAccount(ac._id) const { account, useWebsocket } = obj
accountManager.getAccount(account._id)
.catch((err) => { .catch((err) => {
log.error(err) log.error(err)
event.sender.send('error-start-directmessages-streaming', err) event.sender.send('error-start-directmessages-streaming', err)
}) })
.then((account) => { .then((acct) => {
// Stop old directmessages streaming // Stop old directmessages streaming
if (directMessagesStreaming !== null) { if (directMessagesStreaming !== null) {
directMessagesStreaming.stop() directMessagesStreaming.stop()
directMessagesStreaming = null directMessagesStreaming = null
} }
directMessagesStreaming = new StreamingManager(account) directMessagesStreaming = new StreamingManager(acct, useWebsocket)
directMessagesStreaming.start( directMessagesStreaming.start(
'direct', 'direct',
'', '',

View File

@ -316,7 +316,10 @@ const TimelineSpace = {
}, },
startDirectMessagesStreaming ({ state }) { startDirectMessagesStreaming ({ state }) {
return new Promise((resolve, reject) => { 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) => { ipcRenderer.once('error-start-directmessages-streaming', (event, err) => {
reject(err) reject(err)
}) })