Fix:Set server settings after user logs in

This commit is contained in:
advplyr 2022-07-19 16:40:50 -05:00
parent db1d6da491
commit 7188089f63
4 changed files with 4 additions and 12 deletions

View file

@ -285,14 +285,16 @@ export default {
var payload = await this.requestServerLogin()
this.processing = false
if (payload) {
this.setUserAndConnection(payload.user, payload.userDefaultLibraryId)
this.setUserAndConnection(payload)
}
},
async setUserAndConnection(user, userDefaultLibraryId) {
async setUserAndConnection({ user, userDefaultLibraryId, serverSettings }) {
if (!user) return
console.log('Successfully logged in', JSON.stringify(user))
this.$store.commit('setServerSettings', data.serverSettings)
// Set library - Use last library if set and available fallback to default user library
var lastLibraryId = await this.$localStore.getLastLibraryId()
if (lastLibraryId && (!user.librariesAccessible.length || user.librariesAccessible.includes(lastLibraryId))) {

View file

@ -154,9 +154,6 @@ export default {
socketConnectionFailed(err) {
this.$toast.error('Socket connection error: ' + err.message)
},
socketInit(data) {
console.log('Socket init', data)
},
async initLibraries() {
if (this.inittingLibraries) {
return
@ -255,7 +252,6 @@ export default {
}
},
async mounted() {
this.$socket.on('initialized', this.socketInit)
this.$socket.on('user_updated', this.userUpdated)
this.$socket.on('user_media_progress_updated', this.userMediaProgressUpdated)
@ -283,7 +279,6 @@ export default {
}
},
beforeDestroy() {
this.$socket.off('initialized', this.socketInit)
this.$socket.off('user_updated', this.userUpdated)
this.$socket.off('user_media_progress_updated', this.userMediaProgressUpdated)
}

View file

@ -183,12 +183,10 @@ export default {
})
},
initListeners() {
// this.$server.on('initialized', this.socketInit)
this.$eventBus.$on('library-changed', this.libraryChanged)
// this.$eventBus.$on('downloads-loaded', this.downloadsLoaded)
},
removeListeners() {
// this.$server.off('initialized', this.socketInit)
this.$eventBus.$off('library-changed', this.libraryChanged)
// this.$eventBus.$off('downloads-loaded', this.downloadsLoaded)
}

View file

@ -80,9 +80,6 @@ class ServerSocket extends EventEmitter {
onInit(data) {
console.log('[SOCKET] Initial socket data received', data)
if (data.serverSettings) {
this.$store.commit('setServerSettings', data.serverSettings)
}
this.emit('initialized', true)
}