Skip to content

Commit 0a0d229

Browse files
authored
fix: STRF-11856 - Filter list of channels from getStoreChannels() to storefront channels (#1180)
2 parents 718ee9f + 4376c9e commit 0a0d229

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

lib/theme-api-client.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,23 @@ async function getChannelActiveTheme({ accessToken, apiHost, storeHash, channelI
208208
*/
209209
async function getStoreChannels({ accessToken, apiHost, storeHash }) {
210210
try {
211-
const response = await networkUtils.sendApiRequest({
211+
const sitesResponse = await networkUtils.sendApiRequest({
212212
url: `${apiHost}/stores/${storeHash}/v3/sites`,
213213
accessToken,
214214
});
215-
return response.data.data;
215+
const channelsResponse = await networkUtils.sendApiRequest({
216+
url: `${apiHost}/stores/${storeHash}/v3/channels`,
217+
accessToken,
218+
});
219+
220+
const storefrontChannels = channelsResponse.data.data.filter(
221+
(channel) => channel.type === 'storefront',
222+
);
223+
224+
return sitesResponse.data.data.filter(
225+
(site) =>
226+
storefrontChannels.filter((channel) => channel.id === site.channel_id).length > 0,
227+
);
216228
} catch (err) {
217229
throw new Error(`Could not fetch a list of the store channels: ${err.message}`);
218230
}

0 commit comments

Comments
 (0)