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 28, 2023
1 parent 04f901f commit ccb3798
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 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: 12 additions & 11 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,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 &&
Expand All @@ -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();
}
);

Expand All @@ -1169,6 +1169,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 ccb3798

Please sign in to comment.