1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Fix unhandled promises

This commit is contained in:
Bill Thornton 2024-10-24 01:35:04 -04:00
parent 6530d2d7d8
commit 571b28099e
7 changed files with 26 additions and 7 deletions

View file

@ -27,10 +27,12 @@ const PlayAllButton: FC<PlayAllButtonProps> = ({ item, items, viewType, hasFilte
SortBy: [libraryViewSettings.SortBy],
SortOrder: [libraryViewSettings.SortOrder]
}
}).catch(err => {
console.error('[PlayAllButton] failed to play', err);
});
} else {
playbackManager.play({
items: items,
items,
autoplay: true,
queryOptions: {
ParentId: item?.Id ?? undefined,
@ -38,7 +40,8 @@ const PlayAllButton: FC<PlayAllButtonProps> = ({ item, items, viewType, hasFilte
SortBy: [libraryViewSettings.SortBy],
SortOrder: [libraryViewSettings.SortOrder]
}
}).catch(err => {
console.error('[PlayAllButton] failed to play', err);
});
}
}, [hasFilters, item, items, libraryViewSettings, viewType]);

View file

@ -17,10 +17,14 @@ const QueueButton: FC<QueueButtonProps> = ({ item, items, hasFilters }) => {
if (item && !hasFilters) {
playbackManager.queue({
items: [item]
}).catch(err => {
console.error('[QueueButton] failed to add to queue', err);
});
} else {
playbackManager.queue({
items: items
items
}).catch(err => {
console.error('[QueueButton] failed to add to queue', err);
});
}
}, [hasFilters, item, items]);

View file

@ -24,13 +24,15 @@ const ShuffleButton: FC<ShuffleButtonProps> = ({ item, items, viewType, hasFilte
playbackManager.shuffle(item);
} else {
playbackManager.play({
items: items,
items,
autoplay: true,
queryOptions: {
ParentId: item?.Id ?? undefined,
...getFiltersQuery(viewType, libraryViewSettings),
SortBy: [ItemSortBy.Random]
}
}).catch(err => {
console.error('[ShuffleButton] failed to play', err);
});
}
}, [hasFilters, item, items, libraryViewSettings, viewType]);

View file

@ -39,7 +39,7 @@ function playAllFromHere(opts: PlayAllFromHereOptions) {
}
if (!ids.length) {
return;
return Promise.resolve();
}
if (queue) {
@ -168,6 +168,8 @@ const MoreCommandsButton: FC<MoreCommandsButtonProps> = ({
item: item || {},
items: items || [],
serverId: item?.ServerId
}).catch(err => {
console.error('[MoreCommandsButton] failed to play', err);
});
} else if (result.command === 'queueallfromhere') {
playAllFromHere({
@ -175,6 +177,8 @@ const MoreCommandsButton: FC<MoreCommandsButtonProps> = ({
items: items || [],
serverId: item?.ServerId,
queue: true
}).catch(err => {
console.error('[MoreCommandsButton] failed to play', err);
});
} else if (result.deleted) {
if (result?.itemId !== itemId) {

View file

@ -58,6 +58,8 @@ const PlayOrResumeButton: FC<PlayOrResumeButtonProps> = ({
);
playbackManager.play({
items: [channel]
}).catch(err => {
console.error('[PlayOrResumeButton] failed to play', err);
});
return;
}
@ -65,6 +67,8 @@ const PlayOrResumeButton: FC<PlayOrResumeButtonProps> = ({
playbackManager.play({
items: [item],
...playOptions
}).catch(err => {
console.error('[PlayOrResumeButton] failed to play', err);
});
}, [apiContext, item, playOptions, queryClient]);

View file

@ -3113,11 +3113,11 @@ export class PlaybackManager {
};
self.queue = function (options, player = this._currentPlayer) {
queue(options, '', player);
return queue(options, '', player);
};
self.queueNext = function (options, player = this._currentPlayer) {
queue(options, 'next', player);
return queue(options, 'next', player);
};
function queue(options, mode, player) {

View file

@ -145,6 +145,8 @@ function addToPlaylist(dlg: DialogElement, id: string) {
playbackManager.queue({
serverId: currentServerId,
ids: itemIds.split(',')
}).catch(err => {
console.error('[PlaylistEditor] failed to add to queue', err);
});
dlg.submitted = true;
dialogHelper.close(dlg);