diff --git a/src/components/playlisteditor/playlisteditor.ts b/src/components/playlisteditor/playlisteditor.ts index 75b004cdd5..3db83914e1 100644 --- a/src/components/playlisteditor/playlisteditor.ts +++ b/src/components/playlisteditor/playlisteditor.ts @@ -84,12 +84,12 @@ function onSubmit(this: HTMLElement, e: Event) { } function createPlaylist(dlg: DialogElement) { - const apiClient = ServerConnections.getApiClient(currentServerId); - const api = toApi(apiClient); - const name = dlg.querySelector('#txtNewPlaylistName')?.value; if (isBlank(name)) return Promise.reject(new Error('Playlist name should not be blank')); + const apiClient = ServerConnections.getApiClient(currentServerId); + const api = toApi(apiClient); + const itemIds = dlg.querySelector('.fldSelectedItemIds')?.value || undefined; return getPlaylistsApi(api) @@ -114,14 +114,14 @@ function redirectToPlaylist(id: string | undefined) { } function updatePlaylist(dlg: DialogElement) { - const apiClient = ServerConnections.getApiClient(currentServerId); - const api = toApi(apiClient); - if (!dlg.playlistId) return Promise.reject(new Error('Missing playlist ID')); const name = dlg.querySelector('#txtNewPlaylistName')?.value; if (isBlank(name)) return Promise.reject(new Error('Playlist name should not be blank')); + const apiClient = ServerConnections.getApiClient(currentServerId); + const api = toApi(apiClient); + return getPlaylistsApi(api) .updatePlaylist({ playlistId: dlg.playlistId,