Skip to content

Commit d46784e

Browse files
committed
fix(flags): allow ads on logged out users
1 parent b33b190 commit d46784e

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

clients/web/src/pages/_app.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,28 @@ function PocketWebClient({ Component, pageProps, err }) {
118118

119119
// Hydrate user features/settings
120120
useEffect(() => {
121+
// Sets up feature flags for this user
122+
const hydrateFeatures = async () => {
123+
try {
124+
const locale = navigator.languages
125+
? navigator.languages[0]
126+
: navigator.language || navigator.userLanguage
127+
128+
const response = await fetchUnleashData(user_id, sess_guid, birth, locale)
129+
const features = response ? response : {}
130+
if (features) dispatch(featuresHydrate(features))
131+
} catch {
132+
dispatch(featuresHydrate({}))
133+
}
134+
}
135+
136+
const requestListsPilotStatus = async () => {
137+
dispatch(checkListsPilotStatus())
138+
}
139+
121140
if (user_status === 'pending' || flagsReady) return () => {}
122141
if (user_status === 'invalid') {
123-
dispatch(featuresHydrate({}))
142+
hydrateFeatures()
124143
dispatch(hydrateSettings())
125144
return () => {}
126145
}
@@ -129,21 +148,6 @@ function PocketWebClient({ Component, pageProps, err }) {
129148
dispatch(appSetPreferences())
130149
dispatch(hydrateSettings())
131150

132-
// Sets up feature flags for this user
133-
const hydrateFeatures = async () => {
134-
const locale = navigator.languages
135-
? navigator.languages[0]
136-
: navigator.language || navigator.userLanguage
137-
138-
const response = await fetchUnleashData(user_id, sess_guid, birth, locale)
139-
const features = response ? response : {}
140-
if (features) dispatch(featuresHydrate(features))
141-
}
142-
143-
const requestListsPilotStatus = async () => {
144-
dispatch(checkListsPilotStatus())
145-
}
146-
147151
hydrateFeatures()
148152
requestListsPilotStatus()
149153
}, [user_status, sess_guid, user_id, birth, dispatch, flagsReady])

0 commit comments

Comments
 (0)