mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-05 07:44:38 +00:00
fix: correct error showing instead of client-side exception if release episodes data is failed to load
This commit is contained in:
parent
9f80ff3262
commit
046ef3a9a4
1 changed files with 15 additions and 24 deletions
|
@ -162,32 +162,25 @@ export const ReleasePlayer = (props: { id: number }) => {
|
|||
return;
|
||||
});
|
||||
|
||||
if (data && Object.keys(data).length == 0) {
|
||||
if (!data || (data && Object.keys(data).length == 0)) {
|
||||
_setError("Ошибка получение данных с сервера");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "voiceover") {
|
||||
if (data.types.length > 0) {
|
||||
setVoiceoverInfo(data.types);
|
||||
const preferredVoiceover =
|
||||
data.types.find(
|
||||
(voiceover: any) => voiceover.name === storedPreferredVoiceover
|
||||
) || data.types[0];
|
||||
setSelectedVoiceover(preferredVoiceover);
|
||||
} else {
|
||||
_setError("Ошибка получения озвучек");
|
||||
}
|
||||
setVoiceoverInfo(data.types);
|
||||
const preferredVoiceover =
|
||||
data.types.find(
|
||||
(voiceover: any) => voiceover.name === storedPreferredVoiceover
|
||||
) || data.types[0];
|
||||
setSelectedVoiceover(preferredVoiceover);
|
||||
} else if (type == "sources") {
|
||||
if (data.sources.length > 0) {
|
||||
setSourcesInfo(data.sources);
|
||||
const preferredSource =
|
||||
data.sources.find(
|
||||
(source: any) => source.name === storedPreferredPlayer
|
||||
) || data.sources[0];
|
||||
setSelectedSource(preferredSource);
|
||||
} else {
|
||||
_setError("Ошибка получения источников");
|
||||
}
|
||||
setSourcesInfo(data.sources);
|
||||
const preferredSource =
|
||||
data.sources.find(
|
||||
(source: any) => source.name === storedPreferredPlayer
|
||||
) || data.sources[0];
|
||||
setSelectedSource(preferredSource);
|
||||
} else if (type == "episodes") {
|
||||
if (data.episodes.length === 0) {
|
||||
const remSources = sourcesInfo.filter(
|
||||
|
@ -196,7 +189,7 @@ export const ReleasePlayer = (props: { id: number }) => {
|
|||
setSourcesInfo(remSources);
|
||||
setSelectedSource(remSources[0]);
|
||||
return;
|
||||
} else if (data.episodes.length > 0) {
|
||||
} else {
|
||||
setEpisodeInfo(data.episodes);
|
||||
setSelectedEpisode(data.episodes[0]);
|
||||
|
||||
|
@ -220,8 +213,6 @@ export const ReleasePlayer = (props: { id: number }) => {
|
|||
}
|
||||
setSelectedEpisode(data.episodes[lastWatchedEpisode]);
|
||||
}
|
||||
} else {
|
||||
_setError("Ошибка получения эпизодов");
|
||||
}
|
||||
} else {
|
||||
_setError("Неизвестный тип запроса");
|
||||
|
|
Loading…
Add table
Reference in a new issue