ungate trending (#7696)

This commit is contained in:
Samuel Newman
2025-02-12 16:00:56 +00:00
committed by GitHub
parent 0d1d0d8fbb
commit 7d694f605a
2 changed files with 3 additions and 17 deletions
-1
View File
@@ -7,4 +7,3 @@ export type Gate =
| 'remove_show_latest_button'
| 'test_gate_1'
| 'test_gate_2'
| 'trending_topics_beta'
+3 -16
View File
@@ -1,6 +1,5 @@
import React from 'react'
import {useGate} from '#/lib/statsig/statsig'
import {useLanguagePrefs} from '#/state/preferences/languages'
import {useServiceConfigQuery} from '#/state/queries/service-config'
import {device} from '#/storage'
@@ -14,7 +13,6 @@ const Context = React.createContext<Context>({
})
export function Provider({children}: React.PropsWithChildren<{}>) {
const gate = useGate()
const langPrefs = useLanguagePrefs()
const {data: config, isLoading: isInitialLoad} = useServiceConfigQuery()
const ctx = React.useMemo<Context>(() => {
@@ -45,23 +43,12 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
* the server, we can exit early.
*/
const enabled = Boolean(config?.topicsEnabled)
if (!enabled) {
// cache for next reload
device.set(['trendingBetaEnabled'], enabled)
return {enabled: false}
}
/*
* Service is enabled, but also check statsig in case we're rolling back.
*/
const gateEnabled = gate('trending_topics_beta')
const _enabled = enabled && gateEnabled
// update cache
device.set(['trendingBetaEnabled'], _enabled)
device.set(['trendingBetaEnabled'], enabled)
return {enabled: _enabled}
}, [isInitialLoad, config, gate, langPrefs.contentLanguages])
return {enabled}
}, [isInitialLoad, config, langPrefs.contentLanguages])
return <Context.Provider value={ctx}>{children}</Context.Provider>
}