Move ~/modules to ~/init
This commit is contained in:
parent
0b51fb037f
commit
071eb2fa35
21 changed files with 10 additions and 10 deletions
|
|
@ -1,28 +0,0 @@
|
|||
import { AppModule } from '~/types'
|
||||
import { watchEffect, watch } from '@vue/composition-api'
|
||||
import { useWebSocket, whenever } from '@vueuse/core'
|
||||
|
||||
export const install: AppModule = ({ store }) => {
|
||||
watch(() => store.state.instance.instanceUrl, () => {
|
||||
const url = store.getters['instance/absoluteUrl']('api/v1/activity')
|
||||
.replace(/^http/, 'ws')
|
||||
|
||||
const { data, status, open, close } = useWebSocket(url, {
|
||||
autoReconnect: true,
|
||||
immediate: false
|
||||
})
|
||||
|
||||
watch(() => store.state.auth.authenticated, (authenticated) => {
|
||||
if (authenticated) return open()
|
||||
close()
|
||||
})
|
||||
|
||||
whenever(data, () => {
|
||||
return store.dispatch('ui/websocketEvent', JSON.parse(data.value))
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
console.log('Websocket status:', status.value)
|
||||
})
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue