flip the remaining feature, env and test type imports
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {RichText} from '@atproto/api'
|
||||
import {RichText} from '@bsky.app/sdk/richtext'
|
||||
import {i18n} from '@lingui/core'
|
||||
|
||||
import {parseEmbedPlayerFromUrl} from '#/lib/strings/embed-player'
|
||||
|
||||
Vendored
+1
-2
@@ -1,5 +1,4 @@
|
||||
import {type Did} from '@atproto/api'
|
||||
|
||||
import {type Did} from '@atproto/syntax'
|
||||
import packageJson from '#/../package.json'
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {useMemo, useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {type AppBskyActorDefs, type AppBskyEmbedExternal} from '@atproto/api'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
import {differenceInMinutes} from 'date-fns'
|
||||
|
||||
import {app} from '#/lexicons'
|
||||
import {useDebouncedValue} from '#/lib/hooks/useDebouncedValue'
|
||||
import {cleanError} from '#/lib/strings/errors'
|
||||
import {definitelyUrl} from '#/lib/strings/url-helpers'
|
||||
@@ -33,8 +33,8 @@ export function EditLiveDialog({
|
||||
embed,
|
||||
}: {
|
||||
control: Dialog.DialogControlProps
|
||||
status: AppBskyActorDefs.StatusView
|
||||
embed: AppBskyEmbedExternal.View
|
||||
status: app.bsky.actor.defs.StatusView
|
||||
embed: app.bsky.embed.external.View
|
||||
}) {
|
||||
return (
|
||||
<Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}>
|
||||
@@ -48,8 +48,8 @@ function DialogInner({
|
||||
status,
|
||||
embed,
|
||||
}: {
|
||||
status: AppBskyActorDefs.StatusView
|
||||
embed: AppBskyEmbedExternal.View
|
||||
status: app.bsky.actor.defs.StatusView
|
||||
embed: app.bsky.embed.external.View
|
||||
}) {
|
||||
const control = Dialog.useDialogContext()
|
||||
const {_, i18n} = useLingui()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {useCallback, useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {type AppBskyActorDefs, ToolsOzoneReportDefs} from '@atproto/api'
|
||||
import {type AtUriString} from '@atproto/syntax'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
@@ -16,14 +15,14 @@ import * as Dialog from '#/components/Dialog'
|
||||
import {Loader} from '#/components/Loader'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {com} from '#/lexicons'
|
||||
import {app, com, tools} from '#/lexicons'
|
||||
|
||||
export function GoLiveDisabledDialog({
|
||||
control,
|
||||
status,
|
||||
}: {
|
||||
control: Dialog.DialogControlProps
|
||||
status: AppBskyActorDefs.StatusView
|
||||
status: app.bsky.actor.defs.StatusView
|
||||
}) {
|
||||
return (
|
||||
<Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}>
|
||||
@@ -38,7 +37,7 @@ export function DialogInner({
|
||||
status,
|
||||
}: {
|
||||
control: Dialog.DialogControlProps
|
||||
status: AppBskyActorDefs.StatusView
|
||||
status: app.bsky.actor.defs.StatusView
|
||||
}) {
|
||||
const {_} = useLingui()
|
||||
const client = useAppviewClient()
|
||||
@@ -61,7 +60,7 @@ export function DialogInner({
|
||||
await client.call(
|
||||
com.atproto.moderation.createReport,
|
||||
{
|
||||
reasonType: ToolsOzoneReportDefs.REASONAPPEAL,
|
||||
reasonType: tools.ozone.report.defs.reasonAppeal,
|
||||
subject: {
|
||||
$type: 'com.atproto.repo.strongRef',
|
||||
// a status view's uri is an at-uri produced by the appview
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {useCallback, useMemo} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {Image} from 'expo-image'
|
||||
import {type AppBskyActorDefs, type AppBskyEmbedExternal} from '@atproto/api'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
import {useNavigation} from '@react-navigation/native'
|
||||
import {useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
import {app} from '#/lexicons'
|
||||
import {useOpenLink} from '#/lib/hooks/useOpenLink'
|
||||
import {moderateStatus} from '#/lib/moderation/subjects'
|
||||
import {type NavigationProp} from '#/lib/routes/types'
|
||||
@@ -37,8 +37,8 @@ export function LiveStatusDialog({
|
||||
}: {
|
||||
control: Dialog.DialogControlProps
|
||||
profile: bsky.profile.AnyProfileView
|
||||
status: AppBskyActorDefs.StatusView
|
||||
embed: AppBskyEmbedExternal.View
|
||||
status: app.bsky.actor.defs.StatusView
|
||||
embed: app.bsky.embed.external.View
|
||||
}) {
|
||||
const navigation = useNavigation<NavigationProp>()
|
||||
return (
|
||||
@@ -61,9 +61,9 @@ function DialogInner({
|
||||
status,
|
||||
}: {
|
||||
profile: bsky.profile.AnyProfileView
|
||||
embed: AppBskyEmbedExternal.View
|
||||
embed: app.bsky.embed.external.View
|
||||
navigation: NavigationProp
|
||||
status: AppBskyActorDefs.StatusView
|
||||
status: app.bsky.actor.defs.StatusView
|
||||
}) {
|
||||
const {t: l} = useLingui()
|
||||
const control = Dialog.useDialogContext()
|
||||
@@ -99,9 +99,9 @@ export function LiveStatus({
|
||||
padding = 'xl',
|
||||
onPressOpenProfile,
|
||||
}: {
|
||||
status: AppBskyActorDefs.StatusView
|
||||
status: app.bsky.actor.defs.StatusView
|
||||
profile: bsky.profile.AnyProfileView
|
||||
embed: AppBskyEmbedExternal.View
|
||||
embed: app.bsky.embed.external.View
|
||||
padding?: 'lg' | 'xl'
|
||||
onPressOpenProfile: () => void
|
||||
}) {
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import {useMemo} from 'react'
|
||||
import {
|
||||
type $Typed,
|
||||
type AppBskyActorDefs,
|
||||
AppBskyEmbedExternal,
|
||||
} from '@atproto/api'
|
||||
import {retry} from '@atproto/common-web'
|
||||
import {type l} from '@atproto/lex'
|
||||
import {type l, type $Typed} from '@atproto/lex'
|
||||
import {type AtIdentifierString, AtUri, toDatetimeString} from '@atproto/syntax'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
@@ -30,7 +25,7 @@ import * as Toast from '#/components/Toast'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {getLiveNowHost, getLiveServiceNames} from '#/features/liveNow/utils'
|
||||
import {app, com} from '#/lexicons'
|
||||
import type * as bsky from '#/types/bsky'
|
||||
import * as bsky from '#/types/bsky'
|
||||
|
||||
export * from '#/features/liveNow/utils'
|
||||
|
||||
@@ -48,7 +43,7 @@ const DEFAULT_STATE = {
|
||||
isDisabled: false,
|
||||
isActive: false,
|
||||
record: {},
|
||||
} satisfies AppBskyActorDefs.StatusView
|
||||
} satisfies app.bsky.actor.defs.StatusView
|
||||
|
||||
export type LiveNowConfig = {
|
||||
canGoLive: boolean
|
||||
@@ -135,10 +130,10 @@ export function useActorStatus(actor?: bsky.profile.AnyProfileView) {
|
||||
isDisabled: false,
|
||||
isActive: true,
|
||||
status: 'app.bsky.actor.status#live',
|
||||
embed: shadowed.status.embed as $Typed<AppBskyEmbedExternal.View>, // temp_isStatusValid asserts this
|
||||
embed: shadowed.status.embed as $Typed<app.bsky.embed.external.View>, // temp_isStatusValid asserts this
|
||||
expiresAt: shadowed.status.expiresAt!, // isStatusStillActive asserts this
|
||||
record: shadowed.status.record,
|
||||
} satisfies AppBskyActorDefs.StatusView
|
||||
} satisfies app.bsky.actor.defs.StatusView
|
||||
}
|
||||
return {
|
||||
uri: shadowed.status.uri,
|
||||
@@ -146,10 +141,10 @@ export function useActorStatus(actor?: bsky.profile.AnyProfileView) {
|
||||
isDisabled,
|
||||
isActive: false,
|
||||
status: 'app.bsky.actor.status#live',
|
||||
embed: shadowed.status.embed as $Typed<AppBskyEmbedExternal.View>, // temp_isStatusValid asserts this
|
||||
embed: shadowed.status.embed as $Typed<app.bsky.embed.external.View>, // temp_isStatusValid asserts this
|
||||
expiresAt: shadowed.status.expiresAt!, // isStatusStillActive asserts this
|
||||
record: shadowed.status.record,
|
||||
} satisfies AppBskyActorDefs.StatusView
|
||||
} satisfies app.bsky.actor.defs.StatusView
|
||||
} else {
|
||||
return DEFAULT_STATE
|
||||
}
|
||||
@@ -169,14 +164,14 @@ export function isStatusStillActive(timeStr: string | undefined) {
|
||||
* validate if the status is valid for the acting user e.g. as they go live.
|
||||
*/
|
||||
export function isStatusValidForViewers(
|
||||
status: AppBskyActorDefs.StatusView,
|
||||
status: app.bsky.actor.defs.StatusView,
|
||||
config: LiveNowConfig,
|
||||
) {
|
||||
if (status.status !== 'app.bsky.actor.status#live') return false
|
||||
if (!status.uri) return false // should not happen, just backwards compat
|
||||
try {
|
||||
const {host: liveDid} = new AtUri(status.uri)
|
||||
if (AppBskyEmbedExternal.isView(status.embed)) {
|
||||
if (bsky.isType(app.bsky.embed.external.view, status.embed)) {
|
||||
const host = getLiveNowHost(status.embed.external.uri)
|
||||
const exception = config.allowedHostsExceptionsByDid.get(liveDid)
|
||||
const isValidException = exception ? exception.has(host) : false
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import {AppBskyActorStatus, AppBskyEmbedExternal} from '@atproto/api'
|
||||
import {type I18n} from '@lingui/core'
|
||||
import {plural} from '@lingui/core/macro'
|
||||
import psl from 'psl'
|
||||
import * as bsky from '#/types/bsky'
|
||||
import {app} from '#/lexicons'
|
||||
|
||||
/**
|
||||
* Validates a raw status record and returns the typed record, or null if the
|
||||
@@ -9,11 +10,9 @@ import psl from 'psl'
|
||||
*/
|
||||
export function getValidLiveStatusRecord(
|
||||
statusRecord: unknown,
|
||||
): AppBskyActorStatus.Record | null {
|
||||
if (!AppBskyActorStatus.isRecord(statusRecord)) return null
|
||||
const validation = AppBskyActorStatus.validateRecord(statusRecord)
|
||||
if (!validation.success) return null
|
||||
return validation.value
|
||||
): app.bsky.actor.status.Main | null {
|
||||
if (!bsky.matches(app.bsky.actor.status, statusRecord)) return null
|
||||
return statusRecord
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,7 +22,7 @@ export function getValidLiveStatusRecord(
|
||||
export function getLiveLinkFromStatusRecord(statusRecord: unknown): string {
|
||||
const record = getValidLiveStatusRecord(statusRecord)
|
||||
if (!record) return ''
|
||||
if (!AppBskyEmbedExternal.isMain(record.embed)) return ''
|
||||
if (!bsky.isType(app.bsky.embed.external.main, record.embed)) return ''
|
||||
return record.embed.external.uri
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import {type AppBskyFeedDefs, AppBskyFeedPost} from '@atproto/api'
|
||||
import * as bcp47Match from 'bcp-47-match'
|
||||
import lande from 'lande'
|
||||
|
||||
import * as bsky from '#/types/bsky'
|
||||
import {app} from '#/lexicons'
|
||||
import {hasProp} from '#/lib/type-guards'
|
||||
import {
|
||||
AppLanguage,
|
||||
@@ -61,8 +62,8 @@ function getLocalizedLanguage(
|
||||
}
|
||||
}
|
||||
|
||||
export function getPostLanguageTags(post: AppBskyFeedDefs.PostView) {
|
||||
return AppBskyFeedPost.isRecord(post.record) &&
|
||||
export function getPostLanguageTags(post: app.bsky.feed.defs.PostView) {
|
||||
return bsky.isType(app.bsky.feed.post, post.record) &&
|
||||
hasProp(post.record, 'langs') &&
|
||||
Array.isArray(post.record.langs)
|
||||
? post.record.langs
|
||||
@@ -86,7 +87,7 @@ export function codeToLanguageName(lang2or3: string, appLang: string): string {
|
||||
}
|
||||
|
||||
export function getPostLanguage(
|
||||
post: AppBskyFeedDefs.PostView,
|
||||
post: app.bsky.feed.defs.PostView,
|
||||
): string | undefined {
|
||||
let candidates: string[] = getPostLanguageTags(post)
|
||||
let postText: string = ''
|
||||
@@ -121,7 +122,7 @@ export function getPostLanguage(
|
||||
}
|
||||
|
||||
export function isPostInLanguage(
|
||||
post: AppBskyFeedDefs.PostView,
|
||||
post: app.bsky.feed.defs.PostView,
|
||||
targetLangs: string[],
|
||||
): boolean {
|
||||
const lang = getPostLanguage(post)
|
||||
|
||||
Reference in New Issue
Block a user