[web] Lint source code

This commit is contained in:
Alain Nussbaumer
2025-05-25 10:41:58 +02:00
parent 02625ff67a
commit f62c5c06a8
31 changed files with 217 additions and 218 deletions

View File

@@ -79,17 +79,17 @@ export default {
},
created() {
this.handlers = {
update: [this.libraryStore.initialise],
database: [this.libraryStore.initialise],
player: [this.playerStore.initialise],
lastfm: [this.servicesStore.initialiseLastfm],
options: [this.playerStore.initialise],
volume: [this.playerStore.initialise, this.outputsStore.initialise],
outputs: [this.outputsStore.initialise],
pairing: [this.remotesStore.initialise],
player: [this.playerStore.initialise],
queue: [this.queueStore.initialise],
settings: [this.settingsStore.initialise],
spotify: [this.servicesStore.initialiseSpotify],
lastfm: [this.servicesStore.initialiseLastfm],
pairing: [this.remotesStore.initialise]
update: [this.libraryStore.initialise],
volume: [this.playerStore.initialise, this.outputsStore.initialise]
}
this.connect()
this.$router.beforeEach((to, from, next) => {
@@ -129,6 +129,34 @@ export default {
})
})
},
createWebsocket() {
const protocol = window.location.protocol.replace('http', 'ws')
const hostname =
(import.meta.env.DEV &&
URL.parse(import.meta.env.VITE_OWNTONE_URL)?.hostname) ||
window.location.hostname
const suffix =
this.configurationStore.websocket_port || `${window.location.port}/ws`
const url = `${protocol}${hostname}:${suffix}`
return new ReconnectingWebSocket(url, 'notify', {
maxReconnectInterval: 2000,
reconnectInterval: 1000
})
},
handleEvents(events = []) {
events.forEach((event) => {
const handlers = this.handlers[event] || []
handlers.forEach((handler) => {
if (!this.scheduledHandlers.has(handler)) {
const timeoutId = setTimeout(() => {
handler.call(this)
this.scheduledHandlers.delete(handler)
}, 50)
this.scheduledHandlers.set(handler, timeoutId)
}
})
})
},
openWebsocket() {
const socket = this.createWebsocket()
const events = [
@@ -161,34 +189,6 @@ export default {
this.handleEvents(notifiedEvents)
}
},
createWebsocket() {
const protocol = window.location.protocol.replace('http', 'ws')
const hostname =
(import.meta.env.DEV &&
URL.parse(import.meta.env.VITE_OWNTONE_URL)?.hostname) ||
window.location.hostname
const suffix =
this.configurationStore.websocket_port || `${window.location.port}/ws`
const url = `${protocol}${hostname}:${suffix}`
return new ReconnectingWebSocket(url, 'notify', {
maxReconnectInterval: 2000,
reconnectInterval: 1000
})
},
handleEvents(events = []) {
events.forEach((event) => {
const handlers = this.handlers[event] || []
handlers.forEach((handler) => {
if (!this.scheduledHandlers.has(handler)) {
const timeoutId = setTimeout(() => {
handler.call(this)
this.scheduledHandlers.delete(handler)
}, 50)
this.scheduledHandlers.set(handler, timeoutId)
}
})
})
},
updateClipping() {
if (this.uiStore.showBurgerMenu || this.uiStore.showPlayerMenu) {
document.querySelector('html').classList.add('is-clipped')