From ccb37988932a154709112f087c67bf669f2f1126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Fern=C3=A1ndez?= Date: Tue, 28 Mar 2023 15:26:14 +0200 Subject: [PATCH] fix: minor fixes * Fix MediaSession handling * Remove useless property at taskManager * Fix timeout of sync task not being followed --- .../AppBar/Buttons/TaskManagerButton.vue | 28 +++++++++---------- frontend/src/store/playbackManager.ts | 23 +++++++-------- frontend/src/store/taskManager.ts | 3 -- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/frontend/src/components/Layout/AppBar/Buttons/TaskManagerButton.vue b/frontend/src/components/Layout/AppBar/Buttons/TaskManagerButton.vue index acf00acd7de..b5e2f2c0707 100644 --- a/frontend/src/components/Layout/AppBar/Buttons/TaskManagerButton.vue +++ b/frontend/src/components/Layout/AppBar/Buttons/TaskManagerButton.vue @@ -98,25 +98,23 @@ const buttonColor = computed(() => const UITaskList = computed( () => new Set([ - ...mappedTaskList.value.filter((t) => t.progress !== 100), + ...(menu.value + ? mappedTaskList.value.filter((t) => t.progress !== 100) + : mappedTaskList.value), ...completedTaskList.value ]) ); const showButton = computed(() => UITaskList.value.size > 0); -watch( - [menu, mappedCompleted], - () => { - if (menu.value) { - const ids = new Set(completedTaskList.value.map((t) => t.id)); +watch([menu, mappedCompleted], () => { + if (menu.value) { + const ids = new Set(completedTaskList.value.map((t) => t.id)); - completedTaskList.value.push( - ...mappedCompleted.value.filter((t) => !ids.has(t.id)) - ); - } else { - completedTaskList.value = []; - } - }, - { flush: 'post' } -); + completedTaskList.value.push( + ...mappedCompleted.value.filter((t) => !ids.has(t.id)) + ); + } else { + completedTaskList.value = []; + } +}); diff --git a/frontend/src/store/playbackManager.ts b/frontend/src/store/playbackManager.ts index 3f3df604b3d..c4a9dcac38e 100644 --- a/frontend/src/store/playbackManager.ts +++ b/frontend/src/store/playbackManager.ts @@ -540,7 +540,7 @@ class PlaybackManagerStore { * Updates mediasession metadata based on the currently playing item */ private _updateMediaSessionMetadata = (): void => { - if (this.status !== PlaybackStatus.Stopped && !isNil(this.currentItem)) { + if (!isNil(this.currentItem)) { this._mediaMetadata.title = this.currentItem.Name || ''; this._mediaMetadata.artist = this.currentItem.AlbumArtist || ''; this._mediaMetadata.album = this.currentItem.Album || ''; @@ -1126,15 +1126,13 @@ class PlaybackManagerStore { this._state.currentSourceUrl = this.getItemPlaybackUrl(); } } - - this._updateMediaSessionMetadata(); }; public constructor() { watch( () => this.status, async (newValue, oldValue) => { - const remove = this.status === PlaybackStatus.Stopped; + console.log(newValue); if ( this.status === PlaybackStatus.Playing && @@ -1150,16 +1148,18 @@ class PlaybackManagerStore { if ( newValue === PlaybackStatus.Stopped || - oldValue === PlaybackStatus.Error || - oldValue === PlaybackStatus.Stopped + newValue === PlaybackStatus.Error + ) { + this._handleMediaSession(true); + } else if ( + oldValue === PlaybackStatus.Stopped || + oldValue === PlaybackStatus.Error ) { - this._handleMediaSession(remove); + this._handleMediaSession(); } - if (!remove) { - this._updateMediaSessionStatus(); - await this._reportPlaybackProgress(); - } + this._updateMediaSessionStatus(); + await this._reportPlaybackProgress(); } ); @@ -1169,6 +1169,7 @@ class PlaybackManagerStore { watch( () => this.currentItemIndex, async (newIndex) => { + this._updateMediaSessionMetadata(); await this.fetchCurrentMediaSource(); if (newIndex && !this._state.currentSourceUrl) { diff --git a/frontend/src/store/taskManager.ts b/frontend/src/store/taskManager.ts index 226318ecb30..2617610b0da 100644 --- a/frontend/src/store/taskManager.ts +++ b/frontend/src/store/taskManager.ts @@ -72,9 +72,6 @@ class TaskManagerStore { public get tasks(): typeof this._state.value.tasks { return this._state.value.tasks; } - public set timeout(newTimeout: number) { - this._state.value.finishedTasksTimeout = newTimeout; - } public getTask = (id: string): RunningTask | undefined => this._state.value.tasks.find((payload) => payload.id === id); /**