From 718ad842b36931633bbbb62afbcf434c703de34a Mon Sep 17 00:00:00 2001 From: Travis Shivers Date: Thu, 10 Sep 2020 23:16:46 -0500 Subject: [PATCH] fix(related): return empty array when related fetch fails --- src/store/modules/plexservers/actions.js | 35 ++++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/store/modules/plexservers/actions.js b/src/store/modules/plexservers/actions.js index 3be8de35..c75ccc60 100644 --- a/src/store/modules/plexservers/actions.js +++ b/src/store/modules/plexservers/actions.js @@ -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 }, {