[APP-1759] Live Now Open Beta (#9699)
* Add report dialog to LiveStatus dialog * Mr Worldwide™ * Bug fix bug fix * Copy update * Simplify parsing * Bump api sdk * update dev-env * Update yarn.lock * Bump api sdk * Refactor useActorStatus, add disablement and appeal dialog * Fix types * Guard against chat profile views * Go live (disabled) * Fix types * Update config and gates * Add allowed services * Merge conflicts * Fix gradient handling for nudge * Only show nudge on your own profile * Fix live avi overflow breakage * Add TODO * Feedback * Update nux image --------- Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
@@ -12,6 +12,8 @@ export enum Nux {
|
||||
BookmarksAnnouncement = 'BookmarksAnnouncement',
|
||||
FindContactsAnnouncement = 'FindContactsAnnouncement',
|
||||
FindContactsDismissibleBanner = 'FindContactsDismissibleBanner',
|
||||
LiveNowBetaDialog = 'LiveNowBetaDialog',
|
||||
LiveNowBetaNudge = 'LiveNowBetaNudge',
|
||||
|
||||
/*
|
||||
* Blocking announcements. New IDs are required for each new announcement.
|
||||
@@ -62,6 +64,14 @@ export type AppNux = BaseNux<
|
||||
id: Nux.FindContactsDismissibleBanner
|
||||
data: undefined
|
||||
}
|
||||
| {
|
||||
id: Nux.LiveNowBetaDialog
|
||||
data: undefined
|
||||
}
|
||||
| {
|
||||
id: Nux.LiveNowBetaNudge
|
||||
data: undefined
|
||||
}
|
||||
>
|
||||
|
||||
export const NuxSchemas: Record<Nux, zod.ZodObject<any> | undefined> = {
|
||||
@@ -75,4 +85,6 @@ export const NuxSchemas: Record<Nux, zod.ZodObject<any> | undefined> = {
|
||||
[Nux.BookmarksAnnouncement]: undefined,
|
||||
[Nux.FindContactsAnnouncement]: undefined,
|
||||
[Nux.FindContactsDismissibleBanner]: undefined,
|
||||
[Nux.LiveNowBetaDialog]: undefined,
|
||||
[Nux.LiveNowBetaNudge]: undefined,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import {createContext, useContext, useMemo} from 'react'
|
||||
|
||||
import {useGate} from '#/lib/statsig/statsig'
|
||||
import {useLanguagePrefs} from '#/state/preferences/languages'
|
||||
import {useServiceConfigQuery} from '#/state/queries/service-config'
|
||||
import {useSession} from '#/state/session'
|
||||
import {IS_DEV} from '#/env'
|
||||
import {device} from '#/storage'
|
||||
|
||||
type TrendingContext = {
|
||||
@@ -18,7 +21,7 @@ const TrendingContext = createContext<TrendingContext>({
|
||||
})
|
||||
TrendingContext.displayName = 'TrendingContext'
|
||||
|
||||
const LiveNowContext = createContext<LiveNowContext | null>(null)
|
||||
const LiveNowContext = createContext<LiveNowContext>([])
|
||||
LiveNowContext.displayName = 'LiveNowContext'
|
||||
|
||||
const CheckEmailConfirmedContext = createContext<boolean | null>(null)
|
||||
@@ -82,19 +85,28 @@ export function useTrendingConfig() {
|
||||
return useContext(TrendingContext)
|
||||
}
|
||||
|
||||
export function useLiveNowConfig() {
|
||||
const DEFAULT_LIVE_ALLOWED_DOMAINS = ['twitch.tv', 'www.twitch.tv']
|
||||
export type LiveNowConfig = {
|
||||
allowedDomains: Set<string>
|
||||
}
|
||||
export function useLiveNowConfig(): LiveNowConfig {
|
||||
const ctx = useContext(LiveNowContext)
|
||||
if (!ctx) {
|
||||
throw new Error(
|
||||
'useLiveNowConfig must be used within a ServiceConfigManager',
|
||||
)
|
||||
const canGoLive = useCanGoLive()
|
||||
const {currentAccount} = useSession()
|
||||
if (!currentAccount?.did || !canGoLive) return {allowedDomains: new Set()}
|
||||
const vip = ctx.find(live => live.did === currentAccount.did)
|
||||
return {
|
||||
allowedDomains: new Set(
|
||||
DEFAULT_LIVE_ALLOWED_DOMAINS.concat(vip ? vip.domains : []),
|
||||
),
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
export function useCanGoLive(did?: string) {
|
||||
const config = useLiveNowConfig()
|
||||
return !!config.find(cfg => cfg.did === did)
|
||||
export function useCanGoLive() {
|
||||
const gate = useGate()
|
||||
const {hasSession} = useSession()
|
||||
if (!hasSession) return false
|
||||
return IS_DEV ? true : gate('live_now_beta')
|
||||
}
|
||||
|
||||
export function useCheckEmailConfirmed() {
|
||||
|
||||
Reference in New Issue
Block a user