migrate the threadgate and postgate records to the pds client
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import {type ImagePickerAsset} from 'expo-image-picker'
|
||||
import {
|
||||
type AppBskyActorDefs,
|
||||
type AppBskyDraftDefs,
|
||||
type AppBskyFeedPostgate,
|
||||
} from '@atproto/api'
|
||||
import {type AppBskyActorDefs, type AppBskyDraftDefs} from '@atproto/api'
|
||||
import {type AtUriString, toDatetimeString} from '@atproto/syntax'
|
||||
import {RichText} from '@bsky.app/sdk/richtext'
|
||||
import {nanoid} from 'nanoid/non-secure'
|
||||
|
||||
@@ -103,7 +100,7 @@ export type PostAction =
|
||||
|
||||
export type ThreadDraft = {
|
||||
posts: PostDraft[]
|
||||
postgate: AppBskyFeedPostgate.Record
|
||||
postgate: app.bsky.feed.postgate.Main
|
||||
threadgate: ThreadgateAllowUISetting[]
|
||||
}
|
||||
|
||||
@@ -122,7 +119,7 @@ export type ComposerState = {
|
||||
}
|
||||
|
||||
export type ComposerAction =
|
||||
| {type: 'update_postgate'; postgate: AppBskyFeedPostgate.Record}
|
||||
| {type: 'update_postgate'; postgate: app.bsky.feed.postgate.Main}
|
||||
| {type: 'update_threadgate'; threadgate: ThreadgateAllowUISetting[]}
|
||||
| {
|
||||
type: 'update_post'
|
||||
@@ -319,13 +316,18 @@ export function composerReducer(
|
||||
posts,
|
||||
postgate: createPostgateRecord({
|
||||
post: '',
|
||||
embeddingRules: postgateEmbeddingRules,
|
||||
/*
|
||||
* Draft records are still typed against the legacy client, so the
|
||||
* stored rules arrive unbranded. Wave B migrates the draft types.
|
||||
*/
|
||||
embeddingRules:
|
||||
postgateEmbeddingRules as app.bsky.feed.postgate.Main['embeddingRules'],
|
||||
}),
|
||||
threadgate: threadgateRecordToAllowUISetting({
|
||||
$type: 'app.bsky.feed.threadgate',
|
||||
post: '',
|
||||
createdAt: new Date().toString(),
|
||||
allow: threadgateAllow,
|
||||
post: '' as AtUriString,
|
||||
createdAt: toDatetimeString(new Date()),
|
||||
allow: threadgateAllow as app.bsky.feed.threadgate.Main['allow'],
|
||||
}),
|
||||
},
|
||||
}
|
||||
@@ -744,13 +746,19 @@ export function createComposerState({
|
||||
],
|
||||
postgate: createPostgateRecord({
|
||||
post: '',
|
||||
embeddingRules: initInteractionSettings?.postgateEmbeddingRules || [],
|
||||
/*
|
||||
* Preferences are still typed against the legacy client, so the stored
|
||||
* rules arrive unbranded. Wave B migrates `getPreferences`.
|
||||
*/
|
||||
embeddingRules: (initInteractionSettings?.postgateEmbeddingRules ||
|
||||
[]) as app.bsky.feed.postgate.Main['embeddingRules'],
|
||||
}),
|
||||
threadgate: threadgateRecordToAllowUISetting({
|
||||
$type: 'app.bsky.feed.threadgate',
|
||||
post: '',
|
||||
createdAt: new Date().toString(),
|
||||
allow: initInteractionSettings?.threadgateAllowRules,
|
||||
post: '' as AtUriString,
|
||||
createdAt: toDatetimeString(new Date()),
|
||||
allow:
|
||||
initInteractionSettings?.threadgateAllowRules as app.bsky.feed.threadgate.Main['allow'],
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {useEffect, useMemo, useState} from 'react'
|
||||
import {Keyboard, type StyleProp, type ViewStyle} from 'react-native'
|
||||
import {type AnimatedStyle} from 'react-native-reanimated'
|
||||
import {type AppBskyFeedPostgate} from '@atproto/api'
|
||||
import {type AtUriString, toDatetimeString} from '@atproto/syntax'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
import deepEqual from 'fast-deep-equal'
|
||||
|
||||
@@ -24,6 +24,7 @@ import {Group3_Stroke2_Corner0_Rounded as GroupIcon} from '#/components/icons/Gr
|
||||
import * as Tooltip from '#/components/Tooltip'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
import {type app} from '#/lexicons'
|
||||
import {useThreadgateNudged} from '#/storage/hooks/threadgate-nudged'
|
||||
|
||||
export function ThreadgateBtn({
|
||||
@@ -32,8 +33,8 @@ export function ThreadgateBtn({
|
||||
threadgateAllowUISettings,
|
||||
onChangeThreadgateAllowUISettings,
|
||||
}: {
|
||||
postgate: AppBskyFeedPostgate.Record
|
||||
onChangePostgate: (v: AppBskyFeedPostgate.Record) => void
|
||||
postgate: app.bsky.feed.postgate.Main
|
||||
onChangePostgate: (v: app.bsky.feed.postgate.Main) => void
|
||||
|
||||
threadgateAllowUISettings: ThreadgateAllowUISetting[]
|
||||
onChangeThreadgateAllowUISettings: (v: ThreadgateAllowUISetting[]) => void
|
||||
@@ -83,14 +84,20 @@ export function ThreadgateBtn({
|
||||
|
||||
const prefThreadgateAllowUISettings = threadgateRecordToAllowUISetting({
|
||||
$type: 'app.bsky.feed.threadgate',
|
||||
post: '',
|
||||
createdAt: new Date().toISOString(),
|
||||
allow: preferences?.postInteractionSettings.threadgateAllowRules,
|
||||
post: '' as AtUriString,
|
||||
createdAt: toDatetimeString(new Date()),
|
||||
/*
|
||||
* Preferences are still typed against the legacy client, so the stored
|
||||
* rules arrive unbranded. Wave B migrates `getPreferences`.
|
||||
*/
|
||||
allow: preferences?.postInteractionSettings
|
||||
.threadgateAllowRules as app.bsky.feed.threadgate.Main['allow'],
|
||||
})
|
||||
const prefPostgate = createPostgateRecord({
|
||||
post: '',
|
||||
embeddingRules:
|
||||
preferences?.postInteractionSettings?.postgateEmbeddingRules || [],
|
||||
embeddingRules: (preferences?.postInteractionSettings
|
||||
?.postgateEmbeddingRules ||
|
||||
[]) as app.bsky.feed.postgate.Main['embeddingRules'],
|
||||
})
|
||||
|
||||
const isDirty = useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user