flip the remaining feature, env and test type imports

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