Skip to content
Snippets Groups Projects
Verified Commit ef224e9f authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Fixed #287: duplicated websocket connexion on timeline

parent 4c81de92
No related branches found
No related tags found
No related merge requests found
Fixed duplicated websocket connexion on timeline (#287)
......@@ -34,6 +34,7 @@ export default {
data () {
return {
isLoading: false,
bridge: null,
components: {
'Like': Like,
'Listen': Listen
......@@ -44,6 +45,9 @@ export default {
this.openWebsocket()
this.fetchEvents()
},
destroyed () {
this.disconnect()
},
computed: {
...mapState({
events: state => state.instance.events
......@@ -58,14 +62,22 @@ export default {
self.$store.commit('instance/events', response.data.results)
})
},
disconnect () {
if (!this.bridge) {
return
}
this.bridge.socket.close(1000, 'goodbye', {keepClosed: true})
},
openWebsocket () {
if (!this.$store.state.auth.authenticated) {
return
}
this.disconnect()
let self = this
let token = this.$store.state.auth.token
// let token = 'test'
const bridge = new WebSocketBridge()
this.bridge = bridge
bridge.connect(
`/api/v1/instance/activity?token=${token}`,
null,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment