From 8677e8376ade04a7544be45f700bab535a652c2e Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 29 May 2019 14:36:34 -0700 Subject: [PATCH] Hide blessed packs section if we don't have any blessed packs --- ts/components/stickers/StickerManager.md | 8 +-- ts/components/stickers/StickerManager.tsx | 63 +++++++++++++---------- 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/ts/components/stickers/StickerManager.md b/ts/components/stickers/StickerManager.md index 590af0942b..ee159102e4 100644 --- a/ts/components/stickers/StickerManager.md +++ b/ts/components/stickers/StickerManager.md @@ -55,7 +55,7 @@ const blessedPacks = packs.map(p => ({ ; ``` -#### No Advertised Packs +#### Only installed packs ```jsx const sticker1 = { id: 1, url: util.kitten164ObjectUrl, packId: 'foo' }; @@ -107,7 +107,7 @@ const noPacks = []; ; ``` -#### No Installed Packs +#### Only received packs ```jsx const sticker1 = { id: 1, url: util.kitten164ObjectUrl, packId: 'foo' }; @@ -158,7 +158,7 @@ const noPacks = []; ; ``` -#### No with 'known' +#### Just installed and 'known' ```jsx const sticker1 = { id: 1, url: util.kitten164ObjectUrl, packId: 'foo' }; @@ -216,7 +216,7 @@ const noPacks = []; ; ``` -#### No Packs at All +#### No packs at All ```jsx const noPacks = []; diff --git a/ts/components/stickers/StickerManager.tsx b/ts/components/stickers/StickerManager.tsx index a43d5e138e..e9e015f47b 100644 --- a/ts/components/stickers/StickerManager.tsx +++ b/ts/components/stickers/StickerManager.tsx @@ -75,45 +75,54 @@ export const StickerManager = React.memo( i18nKey: 'stickers--StickerManager--InstalledPacks', i18nEmptyKey: 'stickers--StickerManager--InstalledPacks--Empty', packs: installedPacks, + hideIfEmpty: false, }, { i18nKey: 'stickers--StickerManager--BlessedPacks', i18nEmptyKey: 'stickers--StickerManager--BlessedPacks--Empty', packs: blessedPacks, + hideIfEmpty: true, }, { i18nKey: 'stickers--StickerManager--ReceivedPacks', i18nEmptyKey: 'stickers--StickerManager--ReceivedPacks--Empty', packs: receivedPacks, + hideIfEmpty: false, }, - ].map(section => ( - -

{ + if (section.hideIfEmpty && section.packs.length === 0) { + return; + } + + return ( + +

+ {i18n(section.i18nKey)} +

+ {section.packs.length > 0 ? ( + section.packs.map(pack => ( + + )) + ) : ( +
+ {i18n(section.i18nEmptyKey)} +
)} - > - {i18n(section.i18nKey)} -

- {section.packs.length > 0 ? ( - section.packs.map(pack => ( - - )) - ) : ( -
- {i18n(section.i18nEmptyKey)} -
- )} -
- ))} + + ); + })} );