From c05c752c30210edef736739eb5b990b61d7eaedb Mon Sep 17 00:00:00 2001 From: Rishi Balakrishnan Date: Wed, 9 Sep 2026 19:52:10 -0400 Subject: [PATCH] fix(trending): hide topics for other brands (#189) --- src/lib/community/BrandContext.tsx | 4 ++++ src/lib/community/__tests__/BrandContext.test.ts | 14 ++++++++++++++ src/state/service-config.tsx | 8 +++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/lib/community/BrandContext.tsx b/src/lib/community/BrandContext.tsx index e6fb8db4c..34b1c3832 100644 --- a/src/lib/community/BrandContext.tsx +++ b/src/lib/community/BrandContext.tsx @@ -253,6 +253,10 @@ export function useBrand(): ComputedBrandConfig { return useContext(BrandContext) } +export function isBlackskyBrand(config: ComputedBrandConfig): boolean { + return config.metadata.slug === BLACKSKY_CONFIG.metadata.slug +} + /** * Setter for the active brand config. Used by useCommunityBrandSync (native) to * re-theme when the active account resolves to a different community. The value diff --git a/src/lib/community/__tests__/BrandContext.test.ts b/src/lib/community/__tests__/BrandContext.test.ts index 905b45eb2..563ed6156 100644 --- a/src/lib/community/__tests__/BrandContext.test.ts +++ b/src/lib/community/__tests__/BrandContext.test.ts @@ -5,6 +5,7 @@ import { BRAND_DOMAIN, DEFAULT_BRAND_CONFIG, ensureFollowingPinned, + isBlackskyBrand, } from '../BrandContext' describe('BrandContext defaults', () => { @@ -76,6 +77,19 @@ describe('BrandContext defaults', () => { expect(DEFAULT_BRAND_CONFIG.theme.css.selectionLight).toBe('#D2FC51') expect(DEFAULT_BRAND_CONFIG.theme.css.selectionDark).toBe('#464985') }) + + it('identifies only the Blacksky brand', () => { + expect(isBlackskyBrand(DEFAULT_BRAND_CONFIG)).toBe(true) + expect( + isBlackskyBrand({ + ...DEFAULT_BRAND_CONFIG, + metadata: { + ...DEFAULT_BRAND_CONFIG.metadata, + slug: 'medsky', + }, + }), + ).toBe(false) + }) }) describe('ensureFollowingPinned', () => { diff --git a/src/state/service-config.tsx b/src/state/service-config.tsx index 4103eca05..48410dc20 100644 --- a/src/state/service-config.tsx +++ b/src/state/service-config.tsx @@ -1,5 +1,6 @@ import {createContext, useContext, useMemo} from 'react' +import {isBlackskyBrand, useBrand} from '#/lib/community/BrandContext' import {useLanguagePrefs} from '#/state/preferences/languages' import {useServiceConfigQuery} from '#/state/queries/service-config' import {device} from '#/storage' @@ -16,9 +17,14 @@ TrendingContext.displayName = 'TrendingContext' const CheckEmailConfirmedContext = createContext(null) export function Provider({children}: {children: React.ReactNode}) { + const brand = useBrand() const langPrefs = useLanguagePrefs() const {data: config, isLoading: isInitialLoad} = useServiceConfigQuery() const trending = useMemo(() => { + if (!isBlackskyBrand(brand)) { + return {enabled: false} + } + if (__DEV__) { return {enabled: true} } @@ -47,7 +53,7 @@ export function Provider({children}: {children: React.ReactNode}) { device.set(['trendingBetaEnabled'], enabled) return {enabled} - }, [isInitialLoad, langPrefs.contentLanguages]) + }, [brand, isInitialLoad, langPrefs.contentLanguages]) // probably true, so default to true when loading // if the call fails, the query will set it to false for us -- knotmirror 0.0.1