Move validation checks earlier
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user