Skip to content

Commit

Permalink
fix: minor fixes
Browse files Browse the repository at this point in the history
* Fix MediaSession handling
* Remove useless property at taskManager
* Fix timeout of sync task not being followed
  • Loading branch information
ferferga committed Mar 30, 2023
1 parent 04f901f commit d33c8e1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
28 changes: 13 additions & 15 deletions frontend/src/components/Layout/AppBar/Buttons/TaskManagerButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
});
</script>
23 changes: 11 additions & 12 deletions frontend/src/store/playbackManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '';
Expand Down Expand Up @@ -1126,16 +1126,12 @@ class PlaybackManagerStore {
this._state.currentSourceUrl = this.getItemPlaybackUrl();
}
}

this._updateMediaSessionMetadata();
};

public constructor() {
watch(
() => this.status,
async (newValue, oldValue) => {
const remove = this.status === PlaybackStatus.Stopped;

if (
this.status === PlaybackStatus.Playing &&
!mediaControls.playing.value
Expand All @@ -1150,16 +1146,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();
}
);

Expand All @@ -1169,6 +1167,7 @@ class PlaybackManagerStore {
watch(
() => this.currentItemIndex,
async (newIndex) => {
this._updateMediaSessionMetadata();
await this.fetchCurrentMediaSource();

if (newIndex && !this._state.currentSourceUrl) {
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/store/taskManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/**
Expand Down

0 comments on commit d33c8e1

Please sign in to comment.