Commit c6b79bcd authored by Agate's avatar Agate 💬
Browse files

Merge branch '287-websocket' into 'develop'

Resolve "Display bug in Activity"

Closes #287

See merge request funkwhale/funkwhale!250
parents d544ae3c ef224e9f
Fixed duplicated websocket connexion on timeline (#287)
...@@ -34,6 +34,7 @@ export default { ...@@ -34,6 +34,7 @@ export default {
data () { data () {
return { return {
isLoading: false, isLoading: false,
bridge: null,
components: { components: {
'Like': Like, 'Like': Like,
'Listen': Listen 'Listen': Listen
...@@ -44,6 +45,9 @@ export default { ...@@ -44,6 +45,9 @@ export default {
this.openWebsocket() this.openWebsocket()
this.fetchEvents() this.fetchEvents()
}, },
destroyed () {
this.disconnect()
},
computed: { computed: {
...mapState({ ...mapState({
events: state => state.instance.events events: state => state.instance.events
...@@ -58,14 +62,22 @@ export default { ...@@ -58,14 +62,22 @@ export default {
self.$store.commit('instance/events', response.data.results) self.$store.commit('instance/events', response.data.results)
}) })
}, },
disconnect () {
if (!this.bridge) {
return
}
this.bridge.socket.close(1000, 'goodbye', {keepClosed: true})
},
openWebsocket () { openWebsocket () {
if (!this.$store.state.auth.authenticated) { if (!this.$store.state.auth.authenticated) {
return return
} }
this.disconnect()
let self = this let self = this
let token = this.$store.state.auth.token let token = this.$store.state.auth.token
// let token = 'test' // let token = 'test'
const bridge = new WebSocketBridge() const bridge = new WebSocketBridge()
this.bridge = bridge
bridge.connect( bridge.connect(
`/api/v1/instance/activity?token=${token}`, `/api/v1/instance/activity?token=${token}`,
null, 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