mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix floating promises in ts files
This commit is contained in:
parent
aaac4883e3
commit
eedd40159c
25 changed files with 250 additions and 47 deletions
|
@ -99,7 +99,10 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
|||
}
|
||||
|
||||
// Bounce to the correct page in the login flow
|
||||
bounce(firstConnection);
|
||||
bounce(firstConnection)
|
||||
.catch(err => {
|
||||
console.error('[ConnectionRequired] failed to bounce', err);
|
||||
});
|
||||
}, [bounce, navigate]);
|
||||
|
||||
const validateUserAccess = useCallback(async () => {
|
||||
|
@ -109,7 +112,10 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
|||
if ((isAdminRequired || isUserRequired) && !client?.isLoggedIn()) {
|
||||
try {
|
||||
console.warn('[ConnectionRequired] unauthenticated user attempted to access user route');
|
||||
bounce(await ServerConnections.connect());
|
||||
bounce(await ServerConnections.connect())
|
||||
.catch(err => {
|
||||
console.error('[ConnectionRequired] failed to bounce', err);
|
||||
});
|
||||
} catch (ex) {
|
||||
console.warn('[ConnectionRequired] error bouncing from user route', ex);
|
||||
}
|
||||
|
@ -122,7 +128,10 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
|||
const user = await client?.getCurrentUser();
|
||||
if (!user?.Policy?.IsAdministrator) {
|
||||
console.warn('[ConnectionRequired] normal user attempted to access admin route');
|
||||
bounce(await ServerConnections.connect());
|
||||
bounce(await ServerConnections.connect())
|
||||
.catch(err => {
|
||||
console.error('[ConnectionRequired] failed to bounce', err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (ex) {
|
||||
|
@ -143,9 +152,15 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
|||
appRouter.firstConnectionResult = null;
|
||||
|
||||
if (firstConnection && firstConnection.State !== ConnectionState.SignedIn) {
|
||||
handleIncompleteWizard(firstConnection);
|
||||
handleIncompleteWizard(firstConnection)
|
||||
.catch(err => {
|
||||
console.error('[ConnectionRequired] failed to start wizard', err);
|
||||
});
|
||||
} else {
|
||||
validateUserAccess();
|
||||
validateUserAccess()
|
||||
.catch(err => {
|
||||
console.error('[ConnectionRequired] failed to validate user access', err);
|
||||
});
|
||||
}
|
||||
}, [handleIncompleteWizard, validateUserAccess]);
|
||||
|
||||
|
|
|
@ -32,7 +32,11 @@ const Filter: FC<FilterProps> = ({
|
|||
serverId: window.ApiClient.serverId(),
|
||||
filterMenuOptions: getFilterMenuOptions(),
|
||||
setfilters: setViewQuerySettings
|
||||
}).catch(() => {
|
||||
// filter menu closed
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('[Filter] failed to load filter menu', err);
|
||||
});
|
||||
}, [viewQuerySettings, getVisibleFilters, topParentId, getItemTypes, getFilterMenuOptions, setViewQuerySettings]);
|
||||
|
||||
|
|
|
@ -73,6 +73,8 @@ const GenresItemsContainer: FC<GenresItemsContainerProps> = ({
|
|||
centerText: true,
|
||||
showYear: true
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('[GenresItemsContainer] failed to fetch items', err);
|
||||
});
|
||||
}, [getPortraitShape, topParentId]);
|
||||
|
||||
|
|
|
@ -12,7 +12,11 @@ const NewCollection: FC = () => {
|
|||
collectionEditor.show({
|
||||
items: [],
|
||||
serverId: serverId
|
||||
}).catch(() => {
|
||||
// closed collection editor
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('[NewCollection] failed to load collection editor', err);
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
|
|
@ -22,7 +22,11 @@ const SelectView: FC<SelectViewProps> = ({
|
|||
settings: viewQuerySettings,
|
||||
visibleSettings: getVisibleViewSettings(),
|
||||
setviewsettings: setViewQuerySettings
|
||||
}).catch(() => {
|
||||
// view settings closed
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('[SelectView] failed to load view settings', err);
|
||||
});
|
||||
}, [getVisibleViewSettings, viewQuerySettings, setViewQuerySettings]);
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ const Shuffle: FC<ShuffleProps> = ({ itemsResult = {}, topParentId }) => {
|
|||
topParentId as string
|
||||
).then((item) => {
|
||||
playbackManager.shuffle(item);
|
||||
}).catch(err => {
|
||||
console.error('[Shuffle] failed to fetch items', err);
|
||||
});
|
||||
}, [topParentId]);
|
||||
|
||||
|
|
|
@ -25,7 +25,11 @@ const Sort: FC<SortProps> = ({
|
|||
settings: viewQuerySettings,
|
||||
sortOptions: getSortMenuOptions(),
|
||||
setSortValues: setViewQuerySettings
|
||||
}).catch(() => {
|
||||
// sort menu closed
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('[Sort] failed to load sort menu', err);
|
||||
});
|
||||
}, [getSortMenuOptions, viewQuerySettings, setViewQuerySettings]);
|
||||
|
||||
|
|
|
@ -335,9 +335,13 @@ const ViewItemsContainer: FC<ViewItemsContainerProps> = ({
|
|||
|
||||
import('../../components/autoFocuser').then(({ default: autoFocuser }) => {
|
||||
autoFocuser.autoFocus(page);
|
||||
}).catch(err => {
|
||||
console.error('[ViewItemsContainer] failed to load autofocuser', err);
|
||||
});
|
||||
loading.hide();
|
||||
setisLoading(true);
|
||||
}).catch(err => {
|
||||
console.error('[ViewItemsContainer] failed to fetch data', err);
|
||||
});
|
||||
}, [fetchData]);
|
||||
|
||||
|
|
|
@ -66,6 +66,8 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
|||
|
||||
import('../../autoFocuser').then(({ default: autoFocuser }) => {
|
||||
autoFocuser.autoFocus(page);
|
||||
}).catch(err => {
|
||||
console.error('[UserPasswordForm] failed to load autofocuser', err);
|
||||
});
|
||||
|
||||
(page.querySelector('#txtCurrentPassword') as HTMLInputElement).value = '';
|
||||
|
@ -81,7 +83,9 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
|||
return;
|
||||
}
|
||||
|
||||
loadUser();
|
||||
loadUser().catch(err => {
|
||||
console.error('[UserPasswordForm] failed to load user', err);
|
||||
});
|
||||
|
||||
const onSubmit = (e: Event) => {
|
||||
if ((page.querySelector('#txtNewPassword') as HTMLInputElement).value != (page.querySelector('#txtNewPasswordConfirm') as HTMLInputElement).value) {
|
||||
|
@ -109,7 +113,9 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
|||
loading.hide();
|
||||
toast(globalize.translate('PasswordSaved'));
|
||||
|
||||
loadUser();
|
||||
loadUser().catch(err => {
|
||||
console.error('[UserPasswordForm] failed to load user', err);
|
||||
});
|
||||
}, function () {
|
||||
loading.hide();
|
||||
Dashboard.alert({
|
||||
|
@ -132,6 +138,8 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
|||
if (easyPassword) {
|
||||
window.ApiClient.updateEasyPassword(userId, easyPassword).then(function () {
|
||||
onEasyPasswordSaved();
|
||||
}).catch(err => {
|
||||
console.error('[UserPasswordForm] failed to update easy password', err);
|
||||
});
|
||||
} else {
|
||||
onEasyPasswordSaved();
|
||||
|
@ -153,8 +161,14 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
|||
loading.hide();
|
||||
toast(globalize.translate('SettingsSaved'));
|
||||
|
||||
loadUser();
|
||||
loadUser().catch(err => {
|
||||
console.error('[UserPasswordForm] failed to load user', err);
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('[UserPasswordForm] failed to update user configuration', err);
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('[UserPasswordForm] failed to fetch user', err);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -169,8 +183,14 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
|||
message: globalize.translate('PinCodeResetComplete'),
|
||||
title: globalize.translate('HeaderPinCodeReset')
|
||||
});
|
||||
loadUser();
|
||||
loadUser().catch(err => {
|
||||
console.error('[UserPasswordForm] failed to load user', err);
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('[UserPasswordForm] failed to reset easy password', err);
|
||||
});
|
||||
}).catch(() => {
|
||||
// confirm dialog was closed
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -184,8 +204,14 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
|||
message: globalize.translate('PasswordResetComplete'),
|
||||
title: globalize.translate('ResetPassword')
|
||||
});
|
||||
loadUser();
|
||||
loadUser().catch(err => {
|
||||
console.error('[UserPasswordForm] failed to load user', err);
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('[UserPasswordForm] failed to reset user password', err);
|
||||
});
|
||||
}).catch(() => {
|
||||
// confirm dialog was closed
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -79,7 +79,9 @@ const LiveTVSearchResults: FunctionComponent<LiveTVSearchResultsProps> = ({ serv
|
|||
fetchItems(apiClient, {
|
||||
IncludeItemTypes: 'LiveTvProgram',
|
||||
IsMovie: true
|
||||
}).then(result => setMovies(result.Items || []));
|
||||
})
|
||||
.then(result => setMovies(result.Items || []))
|
||||
.catch(() => setMovies([]));
|
||||
// Episodes row
|
||||
fetchItems(apiClient, {
|
||||
IncludeItemTypes: 'LiveTvProgram',
|
||||
|
@ -88,22 +90,30 @@ const LiveTVSearchResults: FunctionComponent<LiveTVSearchResultsProps> = ({ serv
|
|||
IsSports: false,
|
||||
IsKids: false,
|
||||
IsNews: false
|
||||
}).then(result => setEpisodes(result.Items || []));
|
||||
})
|
||||
.then(result => setEpisodes(result.Items || []))
|
||||
.catch(() => setEpisodes([]));
|
||||
// Sports row
|
||||
fetchItems(apiClient, {
|
||||
IncludeItemTypes: 'LiveTvProgram',
|
||||
IsSports: true
|
||||
}).then(result => setSports(result.Items || []));
|
||||
})
|
||||
.then(result => setSports(result.Items || []))
|
||||
.catch(() => setSports([]));
|
||||
// Kids row
|
||||
fetchItems(apiClient, {
|
||||
IncludeItemTypes: 'LiveTvProgram',
|
||||
IsKids: true
|
||||
}).then(result => setKids(result.Items || []));
|
||||
})
|
||||
.then(result => setKids(result.Items || []))
|
||||
.catch(() => setKids([]));
|
||||
// News row
|
||||
fetchItems(apiClient, {
|
||||
IncludeItemTypes: 'LiveTvProgram',
|
||||
IsNews: true
|
||||
}).then(result => setNews(result.Items || []));
|
||||
})
|
||||
.then(result => setNews(result.Items || []))
|
||||
.catch(() => setNews([]));
|
||||
// Programs row
|
||||
fetchItems(apiClient, {
|
||||
IncludeItemTypes: 'LiveTvProgram',
|
||||
|
@ -112,10 +122,13 @@ const LiveTVSearchResults: FunctionComponent<LiveTVSearchResultsProps> = ({ serv
|
|||
IsSports: false,
|
||||
IsKids: false,
|
||||
IsNews: false
|
||||
}).then(result => setPrograms(result.Items || []));
|
||||
})
|
||||
.then(result => setPrograms(result.Items || []))
|
||||
.catch(() => setPrograms([]));
|
||||
// Channels row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'TvChannel' })
|
||||
.then(result => setChannels(result.Items || []));
|
||||
.then(result => setChannels(result.Items || []))
|
||||
.catch(() => setChannels([]));
|
||||
}
|
||||
}, [collectionType, parentId, query, serverId]);
|
||||
|
||||
|
|
|
@ -123,38 +123,48 @@ const SearchResults: FunctionComponent<SearchResultsProps> = ({ serverId = windo
|
|||
if (!collectionType || isMovies(collectionType)) {
|
||||
// Movies row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'Movie' })
|
||||
.then(result => setMovies(result.Items));
|
||||
.then(result => setMovies(result.Items))
|
||||
.catch(() => setMovies([]));
|
||||
}
|
||||
|
||||
// TV Show libraries
|
||||
if (!collectionType || isTVShows(collectionType)) {
|
||||
// Shows row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'Series' })
|
||||
.then(result => setShows(result.Items));
|
||||
.then(result => setShows(result.Items))
|
||||
.catch(() => setShows([]));
|
||||
// Episodes row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'Episode' })
|
||||
.then(result => setEpisodes(result.Items));
|
||||
.then(result => setEpisodes(result.Items))
|
||||
.catch(() => setEpisodes([]));
|
||||
}
|
||||
|
||||
// People are included for Movies and TV Shows
|
||||
if (!collectionType || isMovies(collectionType) || isTVShows(collectionType)) {
|
||||
// People row
|
||||
fetchPeople(apiClient).then(result => setPeople(result.Items));
|
||||
fetchPeople(apiClient)
|
||||
.then(result => setPeople(result.Items))
|
||||
.catch(() => setPeople([]));
|
||||
}
|
||||
|
||||
// Music libraries
|
||||
if (!collectionType || isMusic(collectionType)) {
|
||||
// Playlists row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'Playlist' })
|
||||
.then(results => setPlaylists(results.Items));
|
||||
.then(results => setPlaylists(results.Items))
|
||||
.catch(() => setPlaylists([]));
|
||||
// Artists row
|
||||
fetchArtists(apiClient).then(result => setArtists(result.Items));
|
||||
fetchArtists(apiClient)
|
||||
.then(result => setArtists(result.Items))
|
||||
.catch(() => setArtists([]));
|
||||
// Albums row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'MusicAlbum' })
|
||||
.then(result => setAlbums(result.Items));
|
||||
.then(result => setAlbums(result.Items))
|
||||
.catch(() => setAlbums([]));
|
||||
// Songs row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'Audio' })
|
||||
.then(result => setSongs(result.Items));
|
||||
.then(result => setSongs(result.Items))
|
||||
.catch(() => setSongs([]));
|
||||
}
|
||||
|
||||
// Other libraries do not support in-library search currently
|
||||
|
@ -163,28 +173,37 @@ const SearchResults: FunctionComponent<SearchResultsProps> = ({ serverId = windo
|
|||
fetchItems(apiClient, {
|
||||
MediaTypes: 'Video',
|
||||
ExcludeItemTypes: 'Movie,Episode,TvChannel'
|
||||
}).then(result => setVideos(result.Items));
|
||||
})
|
||||
.then(result => setVideos(result.Items))
|
||||
.catch(() => setVideos([]));
|
||||
// Programs row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'LiveTvProgram' })
|
||||
.then(result => setPrograms(result.Items));
|
||||
.then(result => setPrograms(result.Items))
|
||||
.catch(() => setPrograms([]));
|
||||
// Channels row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'TvChannel' })
|
||||
.then(result => setChannels(result.Items));
|
||||
.then(result => setChannels(result.Items))
|
||||
.catch(() => setChannels([]));
|
||||
// Photo Albums row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'PhotoAlbum' })
|
||||
.then(result => setPhotoAlbums(result.Items));
|
||||
.then(result => setPhotoAlbums(result.Items))
|
||||
.catch(() => setPhotoAlbums([]));
|
||||
// Photos row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'Photo' })
|
||||
.then(result => setPhotos(result.Items));
|
||||
.then(result => setPhotos(result.Items))
|
||||
.catch(() => setPhotos([]));
|
||||
// Audio Books row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'AudioBook' })
|
||||
.then(result => setAudioBooks(result.Items));
|
||||
.then(result => setAudioBooks(result.Items))
|
||||
.catch(() => setAudioBooks([]));
|
||||
// Books row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'Book' })
|
||||
.then(result => setBooks(result.Items));
|
||||
.then(result => setBooks(result.Items))
|
||||
.catch(() => setBooks([]));
|
||||
// Collections row
|
||||
fetchItems(apiClient, { IncludeItemTypes: 'BoxSet' })
|
||||
.then(result => setCollections(result.Items));
|
||||
.then(result => setCollections(result.Items))
|
||||
.catch(() => setCollections([]));
|
||||
}
|
||||
}, [collectionType, fetchArtists, fetchItems, fetchPeople, query, serverId]);
|
||||
|
||||
|
|
|
@ -45,7 +45,11 @@ const SearchSuggestions: FunctionComponent<SearchSuggestionsProps> = ({ parentId
|
|||
parentId: parentId || undefined,
|
||||
enableTotalRecordCount: false
|
||||
})
|
||||
.then(result => setSuggestions(result.data.Items || []));
|
||||
.then(result => setSuggestions(result.data.Items || []))
|
||||
.catch(err => {
|
||||
console.error('[SearchSuggestions] failed to fetch search suggestions', err);
|
||||
setSuggestions([]);
|
||||
});
|
||||
}
|
||||
}, [ api, parentId, user ]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue