Rewrite player component to script setup
This commit is contained in:
parent
8c11b6d0ea
commit
cec34d49fa
15 changed files with 678 additions and 680 deletions
|
|
@ -1,6 +1,14 @@
|
|||
import { InitModule } from '~/types'
|
||||
import {
|
||||
InitModule,
|
||||
ListenWSEvent,
|
||||
PendingReviewEditsWSEvent,
|
||||
PendingReviewReportsWSEvent,
|
||||
PendingReviewRequestsWSEvent,
|
||||
} from '~/types'
|
||||
import { watchEffect, watch } from 'vue'
|
||||
import { useWebSocket, whenever } from '@vueuse/core'
|
||||
import useWebSocketHandler from '~/composables/useWebSocketHandler'
|
||||
import { CLIENT_RADIOS } from '~/utils/clientRadios'
|
||||
|
||||
export const install: InitModule = ({ store }) => {
|
||||
watch(() => store.state.instance.instanceUrl, () => {
|
||||
|
|
@ -25,4 +33,47 @@ export const install: InitModule = ({ store }) => {
|
|||
console.log('Websocket status:', status.value)
|
||||
})
|
||||
}, { immediate: true })
|
||||
|
||||
// WebSocket handlers
|
||||
useWebSocketHandler('inbox.item_added', () => {
|
||||
store.commit('ui/incrementNotifications', { type: 'inbox', count: 1 })
|
||||
})
|
||||
|
||||
useWebSocketHandler('mutation.created', (event) => {
|
||||
store.commit('ui/incrementNotifications', {
|
||||
type: 'pendingReviewEdits',
|
||||
value: (event as PendingReviewEditsWSEvent).pending_review_count
|
||||
})
|
||||
})
|
||||
|
||||
useWebSocketHandler('mutation.updated', (event) => {
|
||||
store.commit('ui/incrementNotifications', {
|
||||
type: 'pendingReviewEdits',
|
||||
value: (event as PendingReviewEditsWSEvent).pending_review_count
|
||||
})
|
||||
})
|
||||
|
||||
useWebSocketHandler('report.created', (event) => {
|
||||
store.commit('ui/incrementNotifications', {
|
||||
type: 'pendingReviewReports',
|
||||
value: (event as PendingReviewReportsWSEvent).unresolved_count
|
||||
})
|
||||
})
|
||||
|
||||
useWebSocketHandler('user_request.created', (event) => {
|
||||
store.commit('ui/incrementNotifications', {
|
||||
type: 'pendingReviewRequests',
|
||||
value: (event as PendingReviewRequestsWSEvent).pending_count
|
||||
})
|
||||
})
|
||||
|
||||
useWebSocketHandler('Listen', (event) => {
|
||||
if (store.state.radios.current && store.state.radios.running) {
|
||||
const { current } = store.state.radios
|
||||
|
||||
if (current.clientOnly) {
|
||||
CLIENT_RADIOS[current.type].handleListen(current, event as ListenWSEvent, store)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue