From 470160ee6f95da2f0708e709f7c6907c66e2f4f7 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 7 Oct 2018 21:44:35 +0900
Subject: [PATCH] Fix bind method when reloading
---
src/renderer/components/TimelineSpace.vue | 4 ++++
src/renderer/store/TimelineSpace.js | 21 +++++++++++++--------
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/renderer/components/TimelineSpace.vue b/src/renderer/components/TimelineSpace.vue
index 61d4bf17..c01b9c1f 100644
--- a/src/renderer/components/TimelineSpace.vue
+++ b/src/renderer/components/TimelineSpace.vue
@@ -73,7 +73,9 @@ export default {
window.removeEventListener('dragover', this.onDragOver)
window.removeEventListener('drop', this.handleDrop)
this.$store.dispatch('TimelineSpace/stopUserStreaming')
+ this.$store.dispatch('TimelineSpace/unbindUserStreaming')
this.$store.dispatch('TimelineSpace/stopLocalStreaming')
+ this.$store.dispatch('TimelineSpace/unbindUserStreaming')
},
methods: {
async clear () {
@@ -120,6 +122,7 @@ export default {
})
}
this.$store.dispatch('TimelineSpace/SideMenu/fetchLists', account)
+ this.$store.dispatch('TimelineSpace/bindUserStreaming', account)
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
.catch(() => {
this.$message({
@@ -127,6 +130,7 @@ export default {
type: 'error'
})
})
+ this.$store.dispatch('TimelineSpace/bindLocalStreaming', account)
this.$store.dispatch('TimelineSpace/startLocalStreaming', account)
this.$store.dispatch('TimelineSpace/fetchEmojis', account)
this.$store.dispatch('TimelineSpace/fetchInstance', account)
diff --git a/src/renderer/store/TimelineSpace.js b/src/renderer/store/TimelineSpace.js
index bd007b2c..6e63e45a 100644
--- a/src/renderer/store/TimelineSpace.js
+++ b/src/renderer/store/TimelineSpace.js
@@ -87,7 +87,7 @@ const TimelineSpace = {
})
})
},
- startUserStreaming ({ state, commit, rootState }, account) {
+ bindUserStreaming ({ commit, rootState }, account) {
ipcRenderer.on('update-start-user-streaming', (event, update) => {
commit('TimelineSpace/Contents/Home/appendTimeline', update, { root: true })
// Sometimes archive old statuses
@@ -109,7 +109,8 @@ const TimelineSpace = {
}
commit('TimelineSpace/SideMenu/changeUnreadNotifications', true, { root: true })
})
-
+ },
+ startUserStreaming (_, account) {
return new Promise((resolve, reject) => {
ipcRenderer.send('start-user-streaming', account)
ipcRenderer.once('error-start-user-streaming', (event, err) => {
@@ -117,7 +118,7 @@ const TimelineSpace = {
})
})
},
- startLocalStreaming ({ state, commit, rootState }, account) {
+ bindLocalStreaming ({ commit, rootState }) {
ipcRenderer.on('update-start-local-streaming', (event, update) => {
commit('TimelineSpace/Contents/Local/appendTimeline', update, { root: true })
if (rootState.TimelineSpace.Contents.Local.heading && Math.random() > 0.8) {
@@ -125,6 +126,8 @@ const TimelineSpace = {
}
commit('TimelineSpace/SideMenu/changeUnreadLocalTimeline', true, { root: true })
})
+ },
+ startLocalStreaming (_, account) {
return new Promise((resolve, reject) => {
ipcRenderer.send('start-local-streaming', account)
ipcRenderer.once('error-start-local-streaming', (event, err) => {
@@ -132,18 +135,20 @@ const TimelineSpace = {
})
})
},
- async stopUserStreaming ({ commit }) {
+ unbindUserStreaming () {
ipcRenderer.removeAllListeners('update-start-user-streaming')
ipcRenderer.removeAllListeners('notification-start-user-streaming')
ipcRenderer.removeAllListeners('error-start-user-streaming')
- ipcRenderer.send('stop-user-streaming')
- return 'stopUserStreaming'
},
- async stopLocalStreaming ({ commit }) {
+ stopUserStreaming () {
+ ipcRenderer.send('stop-user-streaming')
+ },
+ unbindLocalStreaming () {
ipcRenderer.removeAllListeners('error-start-local-streaming')
ipcRenderer.removeAllListeners('update-start-local-streaming')
+ },
+ stopLocalStreaming () {
ipcRenderer.send('stop-local-streaming')
- return 'stopLocalStreaming'
},
watchShortcutEvents ({ commit, dispatch }) {
ipcRenderer.on('CmdOrCtrl+N', () => {