mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-26 19:21:39 +00:00
fix: unnecessary v-models and extra requests
This commit is contained in:
parent
2a5ac8f094
commit
0125f9b3ad
3 changed files with 31 additions and 29 deletions
|
|
@ -63,7 +63,7 @@
|
||||||
<div v-show="isPodcastSearchPage" class="h-full w-0.5 bg-yellow-400 absolute top-0 left-0" />
|
<div v-show="isPodcastSearchPage" class="h-full w-0.5 bg-yellow-400 absolute top-0 left-0" />
|
||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
|
|
||||||
<nuxt-link v-if="socialTrue && isGlobalSharing" :to="`/social`" class="w-full h-20 flex flex-col items-center justify-center text-white text-opacity-80 border-b border-primary border-opacity-70 hover:bg-opacity-40 cursor-pointer relative" :class="isSocialPage ? 'bg-primary bg-opacity-80' : 'bg-bg bg-opacity-60'">
|
<nuxt-link v-if="isGlobalSharing" :to="`/social`" class="w-full h-20 flex flex-col items-center justify-center text-white text-opacity-80 border-b border-primary border-opacity-70 hover:bg-opacity-40 cursor-pointer relative" :class="isSocialPage ? 'bg-primary bg-opacity-80' : 'bg-bg bg-opacity-60'">
|
||||||
<span class="material-icons-outlined">connect_without_contact</span>
|
<span class="material-icons-outlined">connect_without_contact</span>
|
||||||
|
|
||||||
<p class="font-book pt-1.5" style="font-size: 0.9rem">Social</p>
|
<p class="font-book pt-1.5" style="font-size: 0.9rem">Social</p>
|
||||||
|
|
@ -155,13 +155,6 @@ export default {
|
||||||
isGlobalSharing() {
|
isGlobalSharing() {
|
||||||
return this.$store.getters['getServerSetting']('sharedListeningStats')
|
return this.$store.getters['getServerSetting']('sharedListeningStats')
|
||||||
},
|
},
|
||||||
async socialTrue() {
|
|
||||||
let listeningStats = await this.$axios.$get(`/api/social`).catch((err) => {
|
|
||||||
console.error('Failed to load shared user listening sesions', err)
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
return listeningStats != null ? true : false
|
|
||||||
},
|
|
||||||
showingIssues() {
|
showingIssues() {
|
||||||
if (!this.$route.query) return false
|
if (!this.$route.query) return false
|
||||||
return this.libraryBookshelfPage && this.$route.query.filter === 'issues'
|
return this.libraryBookshelfPage && this.$route.query.filter === 'issues'
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="w-full h-px bg-primary my-4" />
|
<div class="w-full h-px bg-primary my-4" />
|
||||||
|
|
||||||
<div v-if="isGlobalSharing" class="flex items-center py-1">
|
<div v-if="isGlobalSharing" class="flex items-center py-1">
|
||||||
<ui-toggle-switch v-model="isSharingActivity" @input="changeSharingSetting" />
|
<ui-toggle-switch v-model="isUserSharing" @input="changeSharingSetting" />
|
||||||
<ui-tooltip text="Share your latest listening activity with other users in the social tab">
|
<ui-tooltip text="Share your latest listening activity with other users in the social tab">
|
||||||
<p class="pl-4">
|
<p class="pl-4">
|
||||||
Share Listening Activity
|
Share Listening Activity
|
||||||
|
|
@ -54,7 +54,8 @@ export default {
|
||||||
password: null,
|
password: null,
|
||||||
newPassword: null,
|
newPassword: null,
|
||||||
confirmPassword: null,
|
confirmPassword: null,
|
||||||
changingPassword: false
|
changingPassword: false,
|
||||||
|
isUserSharing: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -76,14 +77,14 @@ export default {
|
||||||
isGuest() {
|
isGuest() {
|
||||||
return this.usertype === 'guest'
|
return this.usertype === 'guest'
|
||||||
},
|
},
|
||||||
isSharingActivity() {
|
|
||||||
return this.$store.getters['user/getUserSetting']('shareListeningActivity')
|
|
||||||
},
|
|
||||||
isGlobalSharing() {
|
isGlobalSharing() {
|
||||||
return this.$store.getters['getServerSetting']('sharedListeningStats')
|
return this.$store.getters['getServerSetting']('sharedListeningStats')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
init() {
|
||||||
|
this.isUserSharing = this.$store.getters['user/getUserSetting']('shareListeningActivity')
|
||||||
|
},
|
||||||
logout() {
|
logout() {
|
||||||
var rootSocket = this.$root.socket || {}
|
var rootSocket = this.$root.socket || {}
|
||||||
const logoutPayload = {
|
const logoutPayload = {
|
||||||
|
|
@ -131,9 +132,11 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
changeSharingSetting() {
|
changeSharingSetting() {
|
||||||
this.$store.dispatch('user/updateUserSettings', { shareListeningActivity: !this.isSharingActivity })
|
this.$store.dispatch('user/updateUserSettings', { shareListeningActivity: this.isUserSharing})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {}
|
mounted() {
|
||||||
|
this.init()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="w-full h-full overflow-y-auto px-2 py-18 md:p-8">
|
<div class="w-full h-full overflow-y-auto px-2 py-18 md:p-8">
|
||||||
<div class="flex flex-col md:flex-row">
|
<div v-if="this.listeningStats" class="flex flex-col md:flex-row">
|
||||||
<div class="w-200 my-6 mx-auto">
|
<div class="w-200 my-6 mx-auto">
|
||||||
<div class="grid grid-cols-2 content-between">
|
<div class="grid grid-cols-2 content-between">
|
||||||
<h1 class="text-2xl mb-4 font-book">Social</h1>
|
<h1 class="text-2xl mb-4 font-book">Social</h1>
|
||||||
|
|
@ -11,12 +11,12 @@
|
||||||
<span class="material-icons icon-text text-sm">info_outlined</span>
|
<span class="material-icons icon-text text-sm">info_outlined</span>
|
||||||
</p>
|
</p>
|
||||||
</ui-tooltip>
|
</ui-tooltip>
|
||||||
<ui-toggle-switch v-model="isSharingActivity" @input="changeSharingSetting" />
|
<ui-toggle-switch v-model="isUserSharing" @input="changeSharingSetting" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="!users.length">No Other User Sessions</p>
|
<p v-if="!users.length">No Other User Sessions</p>
|
||||||
<template v-for="(user, num) in users">
|
<template v-for="(user, num) in users">
|
||||||
<div :key="user.username" class="w-full py-0.5">
|
<div :key="user.username" class="w-full">
|
||||||
<div class="flex items-center mb-1">
|
<div class="flex items-center mb-1">
|
||||||
<nuxt-link :to="`/item/${user.latest.libraryItemId}`">
|
<nuxt-link :to="`/item/${user.latest.libraryItemId}`">
|
||||||
<ui-tooltip direction="left" :text="Math.round(user.latest.progress * 100) + '%'">
|
<ui-tooltip direction="left" :text="Math.round(user.latest.progress * 100) + '%'">
|
||||||
|
|
@ -36,18 +36,20 @@
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="h-16" />
|
<div v-else>
|
||||||
|
<p class="text-xl text-center">There is no listening activity to display</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import BookCover from '../components/covers/BookCover.vue'
|
|
||||||
import Cover from '../components/modals/item/tabs/Cover.vue'
|
import Cover from '../components/modals/item/tabs/Cover.vue'
|
||||||
export default {
|
export default {
|
||||||
components: { Cover },
|
components: { Cover },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
listeningStats: null
|
listeningStats: null,
|
||||||
|
isUserSharing: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -66,12 +68,16 @@ export default {
|
||||||
this.$store.state.users.users.forEach((u) => (usermap[u.id] = { online: true, session: u.session }))
|
this.$store.state.users.users.forEach((u) => (usermap[u.id] = { online: true, session: u.session }))
|
||||||
return usermap
|
return usermap
|
||||||
},
|
},
|
||||||
isSharingActivity() {
|
|
||||||
return this.$store.getters['user/getUserSetting']('shareListeningActivity')
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async init() {
|
init() {
|
||||||
|
this.getUserSharing()
|
||||||
|
this.loadStats()
|
||||||
|
},
|
||||||
|
getUserSharing() {
|
||||||
|
this.isUserSharing = this.$store.getters['user/getUserSetting']('shareListeningActivity')
|
||||||
|
},
|
||||||
|
async loadStats() {
|
||||||
let listeningStats = await this.$axios.$get(`/api/social`).catch((err) => {
|
let listeningStats = await this.$axios.$get(`/api/social`).catch((err) => {
|
||||||
console.error('Failed to load shared user listening sesions', err)
|
console.error('Failed to load shared user listening sesions', err)
|
||||||
return []
|
return []
|
||||||
|
|
@ -88,8 +94,8 @@ export default {
|
||||||
this.listeningStats = listeningStats
|
this.listeningStats = listeningStats
|
||||||
},
|
},
|
||||||
changeSharingSetting() {
|
changeSharingSetting() {
|
||||||
this.$store.dispatch('user/updateUserSettings', { shareListeningActivity: !this.isSharingActivity })
|
this.$store.dispatch('user/updateUserSettings', { shareListeningActivity: this.isUserSharing})
|
||||||
this.init()
|
this.loadStats()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue