Fix:Listening sessions page showing filtered user for open listening sessions #2136

This commit is contained in:
advplyr 2023-09-24 15:59:29 -05:00
parent 8683fc9fe4
commit 26f520ca4a

View File

@ -53,8 +53,10 @@
</div> </div>
<p v-else class="text-white text-opacity-50">{{ $strings.MessageNoListeningSessions }}</p> <p v-else class="text-white text-opacity-50">{{ $strings.MessageNoListeningSessions }}</p>
<div class="w-full my-8 h-px bg-white/10" />
<!-- open listening sessions table --> <!-- open listening sessions table -->
<p v-if="openListeningSessions.length" class="text-lg mb-4 mt-8">Open Listening Sessions</p> <p v-if="openListeningSessions.length" class="text-lg my-4">Open Listening Sessions</p>
<div v-if="openListeningSessions.length" class="block max-w-full"> <div v-if="openListeningSessions.length" class="block max-w-full">
<table class="userSessionsTable"> <table class="userSessionsTable">
<tr class="bg-primary bg-opacity-40"> <tr class="bg-primary bg-opacity-40">
@ -73,8 +75,7 @@
<p class="text-xs text-gray-400 truncate">{{ session.displayAuthor }}</p> <p class="text-xs text-gray-400 truncate">{{ session.displayAuthor }}</p>
</td> </td>
<td class="hidden md:table-cell"> <td class="hidden md:table-cell">
<p v-if="filteredUserUsername" class="text-xs">{{ filteredUserUsername }}</p> <p class="text-xs">{{ session.user ? session.user.username : 'N/A' }}</p>
<p v-else class="text-xs">{{ session.user ? session.user.username : 'N/A' }}</p>
</td> </td>
<td class="hidden md:table-cell"> <td class="hidden md:table-cell">
<p class="text-xs">{{ getPlayMethodName(session.playMethod) }}</p> <p class="text-xs">{{ getPlayMethodName(session.playMethod) }}</p>
@ -153,8 +154,8 @@ export default {
}, },
filteredUserUsername() { filteredUserUsername() {
if (!this.userFilter) return null if (!this.userFilter) return null
var user = this.users.find((u) => u.id === this.userFilter) const user = this.users.find((u) => u.id === this.userFilter)
return user ? user.username : null return user?.username || null
}, },
dateFormat() { dateFormat() {
return this.$store.state.serverSettings.dateFormat return this.$store.state.serverSettings.dateFormat
@ -273,7 +274,7 @@ export default {
return 'Unknown' return 'Unknown'
}, },
async loadSessions(page) { async loadSessions(page) {
var userFilterQuery = this.selectedUser ? `&user=${this.selectedUser}` : '' const userFilterQuery = this.selectedUser ? `&user=${this.selectedUser}` : ''
const data = await this.$axios.$get(`/api/sessions?page=${page}&itemsPerPage=${this.itemsPerPage}${userFilterQuery}`).catch((err) => { const data = await this.$axios.$get(`/api/sessions?page=${page}&itemsPerPage=${this.itemsPerPage}${userFilterQuery}`).catch((err) => {
console.error('Failed to load listening sessions', err) console.error('Failed to load listening sessions', err)
return null return null