Remove gate and fallback handling

This commit is contained in:
Eric Bailey
2024-09-16 12:36:47 -05:00
committed by Hailey
parent ff19f8daff
commit fca470f5c8
2 changed files with 6 additions and 40 deletions
+5 -37
View File
@@ -19,31 +19,12 @@ type Context = {
dismissActiveNux: () => void dismissActiveNux: () => void
} }
/**
* If we fail to complete a NUX here, it may show again on next reload,
* or if prefs state updates. If `true`, this fallback ensures that the last
* shown NUX won't show again, at least for this session.
*
* This is temporary, and only needed for the 10Milly dialog rn, since we
* aren't snoozing that one in device storage.
*/
let __isSnoozedFallback = false
const queuedNuxs: { const queuedNuxs: {
id: Nux id: Nux
enabled(props: {gate: ReturnType<typeof useGate>}): boolean enabled?: (props: {gate: ReturnType<typeof useGate>}) => boolean
/**
* TEMP only intended for use with the 10Milly dialog rn, since there are no
* other NUX dialogs configured
*/
unsafe_disableSnooze: boolean
}[] = [ }[] = [
{ {
id: Nux.TenMillionDialog, id: Nux.TenMillionDialog,
enabled({gate}) {
return gate('ten_million_dialog')
},
unsafe_disableSnooze: true,
}, },
] ]
@@ -92,30 +73,23 @@ function Inner() {
} }
React.useEffect(() => { React.useEffect(() => {
if (__isSnoozedFallback) return
if (snoozed) return if (snoozed) return
if (!nuxs) return if (!nuxs) return
for (const {id, enabled, unsafe_disableSnooze} of queuedNuxs) { for (const {id, enabled} of queuedNuxs) {
const nux = nuxs.find(nux => nux.id === id) const nux = nuxs.find(nux => nux.id === id)
// check if completed first // check if completed first
if (nux && nux.completed) continue if (nux && nux.completed) continue
// then check gate (track exposure) // then check gate (track exposure)
if (!enabled({gate})) continue if (enabled && !enabled({gate})) continue
// we have a winner // we have a winner
setActiveNux(id) setActiveNux(id)
/** // immediately snooze for a day
* TEMP only intended for use with the 10Milly dialog rn, since there are no snoozeNuxDialog()
* other NUX dialogs configured
*/
if (!unsafe_disableSnooze) {
// immediately snooze for a day
snoozeNuxDialog()
}
// immediately update remote data (affects next reload) // immediately update remote data (affects next reload)
upsertNux({ upsertNux({
@@ -126,12 +100,6 @@ function Inner() {
logger.error(`NUX dialogs: failed to upsert '${id}' NUX`, { logger.error(`NUX dialogs: failed to upsert '${id}' NUX`, {
safeMessage: e.message, safeMessage: e.message,
}) })
/*
* TEMP only intended for use with the 10Milly dialog rn
*/
if (unsafe_disableSnooze) {
__isSnoozedFallback = true
}
}) })
break break
+1 -3
View File
@@ -1,5 +1,3 @@
export type Gate = export type Gate =
// Keep this alphabetic please. // Keep this alphabetic please.
| 'debug_show_feedcontext' 'debug_show_feedcontext' | 'suggested_feeds_interstitial'
| 'suggested_feeds_interstitial'
| 'ten_million_dialog'