Move utils into new dir
This commit is contained in:
@@ -20,13 +20,13 @@ import * as TextField from '#/components/forms/TextField'
|
|||||||
import {Clock_Stroke2_Corner0_Rounded as ClockIcon} from '#/components/icons/Clock'
|
import {Clock_Stroke2_Corner0_Rounded as ClockIcon} from '#/components/icons/Clock'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import {displayDuration, useDebouncedValue} from '#/features/liveNow'
|
||||||
import {LinkPreview} from './LinkPreview'
|
import {LinkPreview} from './LinkPreview'
|
||||||
import {
|
import {
|
||||||
useLiveLinkMetaQuery,
|
useLiveLinkMetaQuery,
|
||||||
useRemoveLiveStatusMutation,
|
useRemoveLiveStatusMutation,
|
||||||
useUpsertLiveStatusMutation,
|
useUpsertLiveStatusMutation,
|
||||||
} from './queries'
|
} from './queries'
|
||||||
import {displayDuration, useDebouncedValue} from './utils'
|
|
||||||
|
|
||||||
export function EditLiveDialog({
|
export function EditLiveDialog({
|
||||||
control,
|
control,
|
||||||
|
|||||||
@@ -12,16 +12,16 @@ import {Admonition} from '#/components/Admonition'
|
|||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import * as TextField from '#/components/forms/TextField'
|
import * as TextField from '#/components/forms/TextField'
|
||||||
import {
|
|
||||||
displayDuration,
|
|
||||||
getLiveServiceNames,
|
|
||||||
useDebouncedValue,
|
|
||||||
} from '#/components/live/utils'
|
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import * as ProfileCard from '#/components/ProfileCard'
|
import * as ProfileCard from '#/components/ProfileCard'
|
||||||
import * as Select from '#/components/Select'
|
import * as Select from '#/components/Select'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useLiveNowConfig} from '#/features/liveNow'
|
import {
|
||||||
|
displayDuration,
|
||||||
|
getLiveServiceNames,
|
||||||
|
useDebouncedValue,
|
||||||
|
useLiveNowConfig,
|
||||||
|
} from '#/features/liveNow'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
import {LinkPreview} from './LinkPreview'
|
import {LinkPreview} from './LinkPreview'
|
||||||
import {useLiveLinkMetaQuery, useUpsertLiveStatusMutation} from './queries'
|
import {useLiveLinkMetaQuery, useUpsertLiveStatusMutation} from './queries'
|
||||||
|
|||||||
@@ -16,9 +16,8 @@ import {updateProfileShadow} from '#/state/cache/profile-shadow'
|
|||||||
import {useAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
import {useDialogContext} from '#/components/Dialog'
|
import {useDialogContext} from '#/components/Dialog'
|
||||||
import {getLiveServiceNames} from '#/components/live/utils'
|
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import {useLiveNowConfig} from '#/features/liveNow'
|
import {getLiveServiceNames, useLiveNowConfig} from '#/features/liveNow'
|
||||||
|
|
||||||
export function useLiveLinkMetaQuery(url: string | null) {
|
export function useLiveLinkMetaQuery(url: string | null) {
|
||||||
const liveNowConfig = useLiveNowConfig()
|
const liveNowConfig = useLiveNowConfig()
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import {useTickEveryMinute} from '#/state/shell'
|
|||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
|
export * from '#/features/liveNow/utils'
|
||||||
|
|
||||||
export const DEFAULT_ALLOWED_DOMAINS = [
|
export const DEFAULT_ALLOWED_DOMAINS = [
|
||||||
'twitch.tv',
|
'twitch.tv',
|
||||||
'stream.place',
|
'stream.place',
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import {useEffect, useState} from 'react'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a debounced version of the input value that only updates after the
|
||||||
|
* specified delay has passed without any changes to the input value.
|
||||||
|
*/
|
||||||
|
export function useDebouncedValue<T>(val: T, delayMs: number): T {
|
||||||
|
const [prev, setPrev] = useState(val)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timeout = setTimeout(() => setPrev(val), delayMs)
|
||||||
|
return () => clearTimeout(timeout)
|
||||||
|
}, [val, delayMs])
|
||||||
|
|
||||||
|
return prev
|
||||||
|
}
|
||||||
@@ -6,8 +6,8 @@ import {
|
|||||||
BSKY_SERVICE_DID,
|
BSKY_SERVICE_DID,
|
||||||
PUBLIC_BSKY_SERVICE,
|
PUBLIC_BSKY_SERVICE,
|
||||||
} from '#/lib/constants'
|
} from '#/lib/constants'
|
||||||
|
import {useDebouncedValue} from '#/lib/hooks/useDebouncedValue'
|
||||||
import {createFullHandle} from '#/lib/strings/handles'
|
import {createFullHandle} from '#/lib/strings/handles'
|
||||||
import {useDebouncedValue} from '#/components/live/utils'
|
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
import {Agent} from '../session/agent'
|
import {Agent} from '../session/agent'
|
||||||
|
|||||||
Reference in New Issue
Block a user