mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-28 14:44:30 +02:00
Adding progress filter, filter dot, current chapter highlighted
This commit is contained in:
parent
9c5f79d54f
commit
b8063b8d94
7 changed files with 59 additions and 12 deletions
|
@ -13,8 +13,8 @@ android {
|
||||||
applicationId "com.audiobookshelf.app"
|
applicationId "com.audiobookshelf.app"
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 16
|
versionCode 17
|
||||||
versionName "0.9.1-beta"
|
versionName "0.9.2-beta"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
aaptOptions {
|
aaptOptions {
|
||||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<audio-player-mini ref="audioPlayerMini" :loading="isLoading" @updateTime="updateTime" @selectPlaybackSpeed="showPlaybackSpeedModal = true" @hook:mounted="audioPlayerMounted" />
|
<audio-player-mini ref="audioPlayerMini" :loading="isLoading" @updateTime="updateTime" @selectPlaybackSpeed="showPlaybackSpeedModal = true" @hook:mounted="audioPlayerMounted" />
|
||||||
</div>
|
</div>
|
||||||
<modals-playback-speed-modal v-model="showPlaybackSpeedModal" :playback-speed.sync="playbackSpeed" @change="changePlaybackSpeed" />
|
<modals-playback-speed-modal v-model="showPlaybackSpeedModal" :playback-speed.sync="playbackSpeed" @change="changePlaybackSpeed" />
|
||||||
<modals-chapters-modal v-model="showChapterModal" :chapters="chapters" @select="selectChapter" />
|
<modals-chapters-modal v-model="showChapterModal" :current-chapter="currentChapter" :chapters="chapters" @select="selectChapter" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@ export default {
|
||||||
lastProgressTimeUpdate: 0,
|
lastProgressTimeUpdate: 0,
|
||||||
showPlaybackSpeedModal: false,
|
showPlaybackSpeedModal: false,
|
||||||
playbackSpeed: 1,
|
playbackSpeed: 1,
|
||||||
showChapterModal: false
|
showChapterModal: false,
|
||||||
|
currentTime: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -46,6 +47,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
currentChapter() {
|
||||||
|
if (!this.audiobook || !this.chapters.length) return null
|
||||||
|
return this.chapters.find((ch) => ch.start <= this.currentTime && ch.end > this.currentTime)
|
||||||
|
},
|
||||||
socketConnected() {
|
socketConnected() {
|
||||||
return this.$store.state.socketConnected
|
return this.$store.state.socketConnected
|
||||||
},
|
},
|
||||||
|
@ -124,6 +129,8 @@ export default {
|
||||||
this.showChapterModal = false
|
this.showChapterModal = false
|
||||||
},
|
},
|
||||||
async cancelStream() {
|
async cancelStream() {
|
||||||
|
this.currentTime = 0
|
||||||
|
|
||||||
if (this.download) {
|
if (this.download) {
|
||||||
if (this.$refs.audioPlayerMini) {
|
if (this.$refs.audioPlayerMini) {
|
||||||
this.$refs.audioPlayerMini.terminateStream()
|
this.$refs.audioPlayerMini.terminateStream()
|
||||||
|
@ -147,6 +154,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateTime(currentTime) {
|
updateTime(currentTime) {
|
||||||
|
this.currentTime = currentTime
|
||||||
|
|
||||||
var diff = currentTime - this.lastProgressTimeUpdate
|
var diff = currentTime - this.lastProgressTimeUpdate
|
||||||
|
|
||||||
if (diff > 4 || diff < 0) {
|
if (diff > 4 || diff < 0) {
|
||||||
|
@ -231,6 +240,7 @@ export default {
|
||||||
|
|
||||||
var currentTime = await this.getDownloadStartTime()
|
var currentTime = await this.getDownloadStartTime()
|
||||||
if (isNaN(currentTime) || currentTime === null) currentTime = 0
|
if (isNaN(currentTime) || currentTime === null) currentTime = 0
|
||||||
|
this.currentTime = currentTime
|
||||||
|
|
||||||
// Update local current time
|
// Update local current time
|
||||||
this.$localStore.setCurrent({
|
this.$localStore.setCurrent({
|
||||||
|
@ -276,6 +286,7 @@ export default {
|
||||||
|
|
||||||
var playlistUrl = stream.clientPlaylistUri
|
var playlistUrl = stream.clientPlaylistUri
|
||||||
var currentTime = stream.clientCurrentTime || 0
|
var currentTime = stream.clientCurrentTime || 0
|
||||||
|
this.currentTime = currentTime
|
||||||
var playOnLoad = this.$store.state.playOnLoad
|
var playOnLoad = this.$store.state.playOnLoad
|
||||||
if (playOnLoad) this.$store.commit('setPlayOnLoad', false)
|
if (playOnLoad) this.$store.commit('setPlayOnLoad', false)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<modals-modal v-model="show" :width="300" height="100%">
|
<modals-modal v-model="show" :width="300" height="100%">
|
||||||
|
<template #outer>
|
||||||
|
<div v-if="currentChapter" class="absolute top-4 left-4 z-40" style="max-width: 80%">
|
||||||
|
<p class="text-white text-lg truncate">Current: {{ currentChapterTitle }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<div class="w-full h-full overflow-hidden absolute top-0 left-0 flex items-center justify-center" @click="show = false">
|
<div class="w-full h-full overflow-hidden absolute top-0 left-0 flex items-center justify-center" @click="show = false">
|
||||||
<div class="w-full overflow-x-hidden overflow-y-auto bg-primary rounded-lg border border-white border-opacity-20" style="max-height: 75%" @click.stop>
|
<div class="w-full overflow-x-hidden overflow-y-auto bg-primary rounded-lg border border-white border-opacity-20" style="max-height: 75%" @click.stop>
|
||||||
<ul class="h-full w-full" role="listbox" aria-labelledby="listbox-label">
|
<ul class="h-full w-full" role="listbox" aria-labelledby="listbox-label">
|
||||||
<template v-for="chapter in chapters">
|
<template v-for="chapter in chapters">
|
||||||
<li :key="chapter.id" class="text-gray-50 select-none relative py-3 cursor-pointer hover:bg-black-400" role="option" @click="clickedOption(chapter)">
|
<li :key="chapter.id" class="text-gray-50 select-none relative py-3 cursor-pointer hover:bg-black-400" :class="currentChapterId === chapter.id ? 'bg-bg bg-opacity-80' : ''" role="option" @click="clickedOption(chapter)">
|
||||||
<div class="flex items-center justify-center px-3">
|
<div class="flex items-center justify-center px-3">
|
||||||
<span class="font-normal block truncate text-lg">{{ chapter.title }}</span>
|
<span class="font-normal block truncate text-lg">{{ chapter.title }}</span>
|
||||||
<div class="flex-grow" />
|
<div class="flex-grow" />
|
||||||
|
@ -25,6 +31,10 @@ export default {
|
||||||
chapters: {
|
chapters: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => []
|
||||||
|
},
|
||||||
|
currentChapter: {
|
||||||
|
type: Object,
|
||||||
|
default: () => null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -38,6 +48,12 @@ export default {
|
||||||
set(val) {
|
set(val) {
|
||||||
this.$emit('input', val)
|
this.$emit('input', val)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
currentChapterId() {
|
||||||
|
return this.currentChapter ? this.currentChapter.id : null
|
||||||
|
},
|
||||||
|
currentChapterTitle() {
|
||||||
|
return this.currentChapter ? this.currentChapter.title : null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -80,6 +80,11 @@ export default {
|
||||||
text: 'Authors',
|
text: 'Authors',
|
||||||
value: 'authors',
|
value: 'authors',
|
||||||
sublist: true
|
sublist: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Progress',
|
||||||
|
value: 'progress',
|
||||||
|
sublist: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -124,6 +129,9 @@ export default {
|
||||||
authors() {
|
authors() {
|
||||||
return this.$store.getters['audiobooks/getUniqueAuthors']
|
return this.$store.getters['audiobooks/getUniqueAuthors']
|
||||||
},
|
},
|
||||||
|
progress() {
|
||||||
|
return ['Read', 'Unread', 'In Progress']
|
||||||
|
},
|
||||||
sublistItems() {
|
sublistItems() {
|
||||||
return (this[this.sublist] || []).map((item) => {
|
return (this[this.sublist] || []).map((item) => {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "audiobookshelf-app",
|
"name": "audiobookshelf-app",
|
||||||
"version": "v0.9.1-beta",
|
"version": "v0.9.2-beta",
|
||||||
"author": "advplyr",
|
"author": "advplyr",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxt --hostname localhost --port 1337",
|
"dev": "nuxt --hostname localhost --port 1337",
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
<p class="font-book">{{ numAudiobooks }} Audiobooks</p>
|
<p class="font-book">{{ numAudiobooks }} Audiobooks</p>
|
||||||
|
|
||||||
<div class="flex-grow" />
|
<div class="flex-grow" />
|
||||||
<span class="material-icons px-2" @click="showFilterModal = true">filter_alt</span>
|
<div class="relative flex items-center px-2">
|
||||||
|
<span class="material-icons" @click="showFilterModal = true">filter_alt</span>
|
||||||
|
<div v-show="hasFilters" class="absolute top-0 right-2 w-2 h-2 rounded-full bg-success border border-green-300 shadow-sm z-10 pointer-events-none" />
|
||||||
|
</div>
|
||||||
<span class="material-icons px-2" @click="showSortModal = true">sort</span>
|
<span class="material-icons px-2" @click="showSortModal = true">sort</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -29,6 +32,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
hasFilters() {
|
||||||
|
return this.$store.getters['user/getUserSetting']('filterBy') !== 'all'
|
||||||
|
},
|
||||||
numAudiobooks() {
|
numAudiobooks() {
|
||||||
return this.$store.getters['audiobooks/getFiltered']().length
|
return this.$store.getters['audiobooks/getFiltered']().length
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,15 +17,11 @@ export const getters = {
|
||||||
return state.audiobooks.find(ab => ab.id === id)
|
return state.audiobooks.find(ab => ab.id === id)
|
||||||
},
|
},
|
||||||
getFiltered: (state, getters, rootState, rootGetters) => () => {
|
getFiltered: (state, getters, rootState, rootGetters) => () => {
|
||||||
// var isDisc = !rootState.networkConnected || !rootState.socketConnected
|
|
||||||
// console.log('GET FILETERED', isDisc)
|
|
||||||
// var filtered = isDisc ? rootGetters['downloads/getAudiobooks'] : state.audiobooks
|
|
||||||
// console.log('FILTERED LEN', filtered.length)
|
|
||||||
var filtered = state.audiobooks
|
var filtered = state.audiobooks
|
||||||
var settings = rootState.user.settings || {}
|
var settings = rootState.user.settings || {}
|
||||||
var filterBy = settings.filterBy || ''
|
var filterBy = settings.filterBy || ''
|
||||||
|
|
||||||
var searchGroups = ['genres', 'tags', 'series', 'authors']
|
var searchGroups = ['genres', 'tags', 'series', 'authors', 'progress']
|
||||||
var group = searchGroups.find(_group => filterBy.startsWith(_group + '.'))
|
var group = searchGroups.find(_group => filterBy.startsWith(_group + '.'))
|
||||||
if (group) {
|
if (group) {
|
||||||
var filter = decode(filterBy.replace(`${group}.`, ''))
|
var filter = decode(filterBy.replace(`${group}.`, ''))
|
||||||
|
@ -33,6 +29,16 @@ export const getters = {
|
||||||
else if (group === 'tags') filtered = filtered.filter(ab => ab.tags.includes(filter))
|
else if (group === 'tags') filtered = filtered.filter(ab => ab.tags.includes(filter))
|
||||||
else if (group === 'series') filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
|
else if (group === 'series') filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
|
||||||
else if (group === 'authors') filtered = filtered.filter(ab => ab.book && ab.book.author === filter)
|
else if (group === 'authors') filtered = filtered.filter(ab => ab.book && ab.book.author === filter)
|
||||||
|
else if (group === 'progress') {
|
||||||
|
filtered = filtered.filter(ab => {
|
||||||
|
var userAudiobook = rootGetters['user/getUserAudiobook'](ab.id)
|
||||||
|
var isRead = userAudiobook && userAudiobook.isRead
|
||||||
|
if (filter === 'Read' && isRead) return true
|
||||||
|
if (filter === 'Unread' && !isRead) return true
|
||||||
|
if (filter === 'In Progress' && (userAudiobook && !userAudiobook.isRead && userAudiobook.progress > 0)) return true
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return filtered
|
return filtered
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue