Move validation checks earlier

This commit is contained in:
Bill Thornton
2024-10-13 16:40:57 -04:00
parent a37388b2e3
commit 3ad0fb02e4

View File

@@ -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<HTMLInputElement>('#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<HTMLInputElement>('.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<HTMLInputElement>('#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,