From a8b48329765b88c6047fcb1aa2e97f8173b728a1 Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 16 Aug 2022 00:12:58 -0700 Subject: [PATCH] Hide the ~owls badge until you type "~owls" Just a cute little way to let us preview it without having to spin up a separate instance of the app or use a feature flag system! This means we can safely merge and push this to production, without worrying about leaking the feature before the ~owls team signs off. --- src/app/ItemPageLayout.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/app/ItemPageLayout.js b/src/app/ItemPageLayout.js index e393a89..38577bb 100644 --- a/src/app/ItemPageLayout.js +++ b/src/app/ItemPageLayout.js @@ -105,6 +105,7 @@ export function SubtleSkeleton({ isLoaded, ...props }) { function ItemPageBadges({ item, isEmbedded }) { const searchBadgesAreLoaded = item?.name != null && item?.isNc != null; + const shouldShowOwls = useShouldShowOwls(); return ( @@ -150,7 +151,7 @@ function ItemPageBadges({ item, isEmbedded }) { Jellyneo - {item.isNc && ( + {item.isNc && shouldShowOwls && ( { + const onKeyPress = (e) => { + const newMostRecentKeys = [...mostRecentKeys, e.key].slice(-5); + if (newMostRecentKeys.join("") === "~owls") { + SHOULD_SHOW_OWLS = true; + setShouldShowOwls(true); + } + setMostRecentKeys(newMostRecentKeys); + }; + + window.addEventListener("keypress", onKeyPress); + return () => window.removeEventListener("keypress", onKeyPress); + }); + + return shouldShowOwls; +} + export default ItemPageLayout;