From 0d4ffd88c02ccd8a88f92967d8470520ec2cec34 Mon Sep 17 00:00:00 2001 From: Steve Rydz Date: Fri, 4 Aug 2023 10:18:00 +0100 Subject: [PATCH] Fix other stores not showing in brand store (#4366) --- .../js/brand-store/components/Snaps/Snaps.tsx | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/static/js/brand-store/components/Snaps/Snaps.tsx b/static/js/brand-store/components/Snaps/Snaps.tsx index b7860e1b08..d10557b5e1 100644 --- a/static/js/brand-store/components/Snaps/Snaps.tsx +++ b/static/js/brand-store/components/Snaps/Snaps.tsx @@ -211,6 +211,14 @@ function SnapsSlice() { const storeIds: Array = []; snaps.forEach((snap) => { + if (snap.store === "ubuntu" || snap.store === id) { + return; + } + + if (!storeIds.includes(snap.store)) { + storeIds.push(snap.store); + } + if (snap?.["other-stores"]?.length) { snap["other-stores"].forEach((otherStoreId) => { if (otherStoreId !== id && !storeIds.includes(otherStoreId)) { @@ -259,10 +267,24 @@ function SnapsSlice() { return { id: storeId, name: getStoreName(storeId), - snaps: snaps.filter( - (snap) => - snap["other-stores"] && snap["other-stores"].includes(storeId) - ), + snaps: snaps.filter((snap) => { + if (storeId === "ubuntu") { + return false; + } + + if (snap.store === storeId) { + return true; + } + + if ( + snap["other-stores"] && + snap["other-stores"].includes(storeId) + ) { + return true; + } + + return false; + }), }; }) );