From c6dc4054be7018af490561455bc514194f282182 Mon Sep 17 00:00:00 2001 From: Austin Philp Date: Fri, 11 Nov 2022 15:41:50 -0800 Subject: [PATCH 1/3] Use `total` from listening-sessions endpoint to display total sessions --- client/pages/config/users/_id/index.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/client/pages/config/users/_id/index.vue b/client/pages/config/users/_id/index.vue index 85f064a7..3cf44921 100644 --- a/client/pages/config/users/_id/index.vue +++ b/client/pages/config/users/_id/index.vue @@ -24,7 +24,7 @@

{{ $strings.HeaderListeningStats }}

-

{{ listeningSessions.length }} {{ $strings.HeaderListeningSessions }}

+

{{ this.listeningSessions.total }} {{ $strings.HeaderListeningSessions }}

{{ $strings.ButtonViewAll }}

@@ -111,6 +111,7 @@ export default { data() { return { listeningSessions: [], + totalSessions: 0, listeningStats: {}, purgingMediaProgress: false } @@ -147,8 +148,8 @@ export default { return this.listeningStats.today || 0 }, latestSession() { - if (!this.listeningSessions.length) return null - return this.listeningSessions[0] + if (!this.listeningSessions.sessions.length) return null + return this.listeningSessions.sessions[0] } }, methods: { @@ -159,11 +160,11 @@ export default { this.listeningSessions = await this.$axios .$get(`/api/users/${this.user.id}/listening-sessions?page=0&itemsPerPage=10`) .then((data) => { - return data.sessions || [] + return data || {} }) .catch((err) => { console.error('Failed to load listening sesions', err) - return [] + return {} }) this.listeningStats = await this.$axios.$get(`/api/users/${this.user.id}/listening-stats`).catch((err) => { console.error('Failed to load listening sesions', err) @@ -221,4 +222,4 @@ export default { padding: 4px 8px; font-size: 0.75rem; } - \ No newline at end of file + From eb295453fcf47388eb3ed97004c23bd1c2934f45 Mon Sep 17 00:00:00 2001 From: Austin Philp Date: Fri, 11 Nov 2022 15:47:20 -0800 Subject: [PATCH 2/3] Cleanup --- client/pages/config/users/_id/index.vue | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/pages/config/users/_id/index.vue b/client/pages/config/users/_id/index.vue index 3cf44921..d09dc44a 100644 --- a/client/pages/config/users/_id/index.vue +++ b/client/pages/config/users/_id/index.vue @@ -24,7 +24,7 @@

{{ $strings.HeaderListeningStats }}

-

{{ this.listeningSessions.total }} {{ $strings.HeaderListeningSessions }}

+

{{ listeningSessions.total }} {{ $strings.HeaderListeningSessions }}

{{ $strings.ButtonViewAll }}

@@ -110,8 +110,7 @@ export default { }, data() { return { - listeningSessions: [], - totalSessions: 0, + listeningSessions: {}, listeningStats: {}, purgingMediaProgress: false } From 3ffc481a540b5312163808955f141b65e28fe84f Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 12 Nov 2022 08:03:13 -0600 Subject: [PATCH 3/3] Fix users latest session computed property --- client/pages/config/users/_id/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/pages/config/users/_id/index.vue b/client/pages/config/users/_id/index.vue index d09dc44a..80ef4c62 100644 --- a/client/pages/config/users/_id/index.vue +++ b/client/pages/config/users/_id/index.vue @@ -147,7 +147,7 @@ export default { return this.listeningStats.today || 0 }, latestSession() { - if (!this.listeningSessions.sessions.length) return null + if (!this.listeningSessions.sessions || !this.listeningSessions.sessions.length) return null return this.listeningSessions.sessions[0] } },