From 3ad0fb02e407d4c6075e9bbff358146db5717b6c Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Sun, 13 Oct 2024 16:40:57 -0400 Subject: [PATCH] Move validation checks earlier --- src/components/playlisteditor/playlisteditor.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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,