mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-26 00:14:49 +01:00
Fix playback sessions num days listened in last year to be accurate for smaller screen sizes
This commit is contained in:
parent
977bdbf0bb
commit
0eed38b771
@ -63,9 +63,6 @@ export default {
|
|||||||
dayOfWeekToday() {
|
dayOfWeekToday() {
|
||||||
return new Date().getDay()
|
return new Date().getDay()
|
||||||
},
|
},
|
||||||
firstWeekStart() {
|
|
||||||
return this.$addDaysToToday(-this.daysToShow)
|
|
||||||
},
|
|
||||||
dayLabels() {
|
dayLabels() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -198,12 +195,25 @@ export default {
|
|||||||
let minValue = 0
|
let minValue = 0
|
||||||
|
|
||||||
const dates = []
|
const dates = []
|
||||||
for (let i = 0; i < this.daysToShow + 1; i++) {
|
|
||||||
const date = i === 0 ? this.firstWeekStart : this.$addDaysToDate(this.firstWeekStart, i)
|
const numDaysInTheLastYear = 52 * 7 + this.dayOfWeekToday
|
||||||
|
const firstDay = this.$addDaysToToday(-numDaysInTheLastYear)
|
||||||
|
for (let i = 0; i < numDaysInTheLastYear + 1; i++) {
|
||||||
|
const date = i === 0 ? firstDay : this.$addDaysToDate(firstDay, i)
|
||||||
const dateString = this.$formatJsDate(date, 'yyyy-MM-dd')
|
const dateString = this.$formatJsDate(date, 'yyyy-MM-dd')
|
||||||
|
|
||||||
|
if (this.daysListening[dateString] > 0) {
|
||||||
|
this.daysListenedInTheLastYear++
|
||||||
|
}
|
||||||
|
|
||||||
|
const visibleDayIndex = i - (numDaysInTheLastYear - this.daysToShow)
|
||||||
|
if (visibleDayIndex < 0) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
const dateObj = {
|
const dateObj = {
|
||||||
col: Math.floor(i / 7),
|
col: Math.floor(visibleDayIndex / 7),
|
||||||
row: i % 7,
|
row: visibleDayIndex % 7,
|
||||||
date,
|
date,
|
||||||
dateString,
|
dateString,
|
||||||
datePretty: this.$formatJsDate(date, 'MMM d, yyyy'),
|
datePretty: this.$formatJsDate(date, 'MMM d, yyyy'),
|
||||||
@ -215,7 +225,6 @@ export default {
|
|||||||
dates.push(dateObj)
|
dates.push(dateObj)
|
||||||
|
|
||||||
if (dateObj.value > 0) {
|
if (dateObj.value > 0) {
|
||||||
this.daysListenedInTheLastYear++
|
|
||||||
if (dateObj.value > maxValue) maxValue = dateObj.value
|
if (dateObj.value > maxValue) maxValue = dateObj.value
|
||||||
if (!minValue || dateObj.value < minValue) minValue = dateObj.value
|
if (!minValue || dateObj.value < minValue) minValue = dateObj.value
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user