Commit c6b79bcd authored by Eliot Berriot's avatar Eliot Berriot 💬

Merge branch '287-websocket' into 'develop'

Resolve "Display bug in Activity"

Closes #287

See merge request !250
parents d544ae3c ef224e9f
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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment