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

Commit

Permalink
fix(libraries): specify manual connection when fetching libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
ttshivers committed Sep 6, 2020
1 parent 611d119 commit 4b3a3cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/store/modules/plex/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ export default {

const libraries = await dispatch('plexservers/FETCH_ALL_LIBRARIES', {
machineIdentifier: device.clientIdentifier,
manualConnection: {
chosenConnection,
accessToken: device.accessToken,
},
}, { root: true });

commit('plexservers/ADD_PLEX_SERVER', {
Expand Down
18 changes: 13 additions & 5 deletions src/store/modules/plexservers/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ export default {
},

FETCH_PLEX_SERVER: ({ getters, rootGetters }, {
machineIdentifier, path, params, ...rest
machineIdentifier, path, params, manualConnection, ...rest
}) => {
const { accessToken, chosenConnection: { uri } } = getters.GET_PLEX_SERVER(machineIdentifier);
const { accessToken, chosenConnection: { uri } } = manualConnection
|| getters.GET_PLEX_SERVER(machineIdentifier);

return fetchJson(
`${uri}${path}`, {
...rootGetters['plex/GET_PLEX_BASE_PARAMS'](accessToken),
Expand Down Expand Up @@ -193,11 +195,12 @@ export default {
return data.MediaContainer.Metadata;
},

FETCH_ALL_LIBRARIES: async ({ dispatch }, { machineIdentifier, signal }) => {
FETCH_ALL_LIBRARIES: async ({ dispatch }, { machineIdentifier, signal, ...rest }) => {
const data = await dispatch('FETCH_PLEX_SERVER', {
machineIdentifier,
path: '/library/sections',
signal,
...rest,
});

return Object.fromEntries(
Expand All @@ -210,6 +213,7 @@ export default {
machineIdentifier,
sectionId: library.key,
signal,
...rest,
}),
},
]),
Expand Down Expand Up @@ -292,7 +296,7 @@ export default {
},

FETCH_LIBRARY_ALL: async ({ dispatch }, {
machineIdentifier, sectionId, start, size, signal,
machineIdentifier, sectionId, start, size, signal, ...rest
}) => {
const { MediaContainer } = await dispatch('FETCH_PLEX_SERVER', {
machineIdentifier,
Expand All @@ -303,6 +307,7 @@ export default {
excludeAllLeaves: 1,
},
signal,
...rest,
});

return MediaContainer;
Expand All @@ -317,13 +322,16 @@ export default {
}));
},

FETCH_LIBRARY_SIZE: async ({ dispatch }, { machineIdentifier, sectionId, signal }) => {
FETCH_LIBRARY_SIZE: async ({ dispatch }, {
machineIdentifier, sectionId, signal, ...rest
}) => {
const { totalSize } = await dispatch('FETCH_LIBRARY_ALL', {
machineIdentifier,
sectionId,
start: 0,
size: 0,
signal,
...rest,
});

return totalSize;
Expand Down

0 comments on commit 4b3a3cf

Please sign in to comment.