mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-29 06:37:16 +02:00
Initial android auto support, fix bug saving user settings
This commit is contained in:
+18
-1
@@ -1,3 +1,4 @@
|
||||
import MyNativeAudio from '@/plugins/my-native-audio'
|
||||
import { sort } from '@/assets/fastSort'
|
||||
import { decode } from '@/plugins/init.client'
|
||||
|
||||
@@ -60,12 +61,13 @@ export const getters = {
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
load({ commit }) {
|
||||
load({ commit, dispatch }) {
|
||||
return this.$axios
|
||||
.$get(`/api/audiobooks`)
|
||||
.then((data) => {
|
||||
console.log('Audiobooks request data', data)
|
||||
commit('set', data)
|
||||
dispatch('setNativeAudiobooks')
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed', error)
|
||||
@@ -73,6 +75,21 @@ export const actions = {
|
||||
},
|
||||
useDownloaded({ commit, rootGetters }) {
|
||||
commit('set', rootGetters['downloads/getAudiobooks'])
|
||||
},
|
||||
setNativeAudiobooks({ state }) {
|
||||
var audiobooks = state.audiobooks.map(ab => {
|
||||
var _book = ab.book
|
||||
return {
|
||||
id: ab.id,
|
||||
title: _book.title,
|
||||
author: _book.author,
|
||||
duration: ab.duration,
|
||||
size: ab.size,
|
||||
cover: _book.cover || '',
|
||||
series: _book.series || ''
|
||||
}
|
||||
})
|
||||
MyNativeAudio.setAudiobooks({ audiobooks: audiobooks })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-7
@@ -1,5 +1,3 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
export const state = () => ({
|
||||
user: null,
|
||||
localUserAudiobooks: {},
|
||||
@@ -31,15 +29,13 @@ export const getters = {
|
||||
|
||||
export const actions = {
|
||||
async updateUserSettings({ commit }, payload) {
|
||||
|
||||
if (Vue.prototype.$server.connected) {
|
||||
if (this.$server.connected) {
|
||||
var updatePayload = {
|
||||
...payload
|
||||
}
|
||||
return this.$axios.$patch('/api/user/settings', updatePayload).then((result) => {
|
||||
if (result.success) {
|
||||
commit('setSettings', result.settings)
|
||||
console.log('Settings updated', result.settings)
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -80,9 +76,7 @@ export const mutations = {
|
||||
}
|
||||
}
|
||||
if (hasChanges) {
|
||||
console.log('Update settings in local storage')
|
||||
this.$localStore.setUserSettings({ ...state.settings })
|
||||
|
||||
state.settingsListeners.forEach((listener) => {
|
||||
listener.meth(state.settings)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user