Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
fix(related): return empty array when related fetch fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ttshivers committed Sep 11, 2020
1 parent b95c83e commit 718ad84
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/store/modules/plexservers/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,21 +271,26 @@ export default {
FETCH_RELATED: async ({ dispatch }, {
machineIdentifier, ratingKey, count, signal,
}) => {
const { MediaContainer: { Hub, librarySectionID } } = await dispatch('FETCH_PLEX_SERVER', {
machineIdentifier,
path: `/library/metadata/${ratingKey}/related`,
params: {
excludeFields: 'summary',
count,
},
signal,
});

// TODO: potentially include the other hubs too (related director etc...)
return Hub?.[0]?.Metadata?.map((child) => ({
...child,
librarySectionID,
})) || [];
try {
const { MediaContainer: { Hub, librarySectionID } } = await dispatch('FETCH_PLEX_SERVER', {
machineIdentifier,
path: `/library/metadata/${ratingKey}/related`,
params: {
excludeFields: 'summary',
count,
},
signal,
});

// TODO: potentially include the other hubs too (related director etc...)
return Hub?.[0]?.Metadata?.map((child) => ({
...child,
librarySectionID,
})) || [];
} catch (e) {
console.error(e);
return [];
}
},

FETCH_LIBRARY_ALL: async ({ dispatch }, {
Expand Down

0 comments on commit 718ad84

Please sign in to comment.