More prefill
This commit is contained in:
@@ -42,6 +42,7 @@ export interface ComposerOpts {
|
||||
text?: string
|
||||
imageUris?: {uri: string; width: number; height: number; altText?: string}[]
|
||||
videoUri?: {uri: string; width: number; height: number}
|
||||
initFeeds: string[] | undefined
|
||||
}
|
||||
|
||||
type StateContext = ComposerOpts | undefined
|
||||
|
||||
@@ -51,11 +51,10 @@ import {Text} from '#/view/com/util/text/Text'
|
||||
import * as Toast from '#/view/com/util/Toast'
|
||||
import {CenteredView} from '#/view/com/util/Views'
|
||||
import {atoms as a, useTheme} from '#/alf'
|
||||
import {Button as NewButton, ButtonIcon, ButtonText} from '#/components/Button'
|
||||
import {Button as NewButton, ButtonText} from '#/components/Button'
|
||||
import {useRichText} from '#/components/hooks/useRichText'
|
||||
import {ArrowOutOfBox_Stroke2_Corner0_Rounded as Share} from '#/components/icons/ArrowOutOfBox'
|
||||
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
|
||||
import {EditBig_Stroke2_Corner0_Rounded as EditBig} from '#/components/icons/EditBig'
|
||||
import {
|
||||
Heart2_Filled_Stroke2_Corner0_Rounded as HeartFilled,
|
||||
Heart2_Stroke2_Corner0_Rounded as HeartOutline,
|
||||
@@ -267,9 +266,6 @@ export function ProfileFeedScreenInner({
|
||||
},
|
||||
[feedSectionRef],
|
||||
)
|
||||
const isFeedSubmittable =
|
||||
feedInfo.creatorDid === currentAccount?.did &&
|
||||
feedInfo.did === 'did:web:feeed.club'
|
||||
|
||||
const renderHeader = useCallback(() => {
|
||||
return (
|
||||
@@ -287,21 +283,6 @@ export function ProfileFeedScreenInner({
|
||||
}
|
||||
avatarType="algo">
|
||||
<View style={[a.flex_row, a.align_center, a.gap_sm]}>
|
||||
{isFeedSubmittable && (
|
||||
<NewButton
|
||||
size="small"
|
||||
variant="solid"
|
||||
color="primary"
|
||||
shape="round"
|
||||
label={_(msg`Add post to feed`)}
|
||||
onPress={() =>
|
||||
openComposer({
|
||||
initFeeds: [feedInfo.uri],
|
||||
})
|
||||
}>
|
||||
<ButtonIcon icon={EditBig} />
|
||||
</NewButton>
|
||||
)}
|
||||
{feedInfo && hasSession && (
|
||||
<NewButton
|
||||
testID={isPinned ? 'unpinBtn' : 'pinBtn'}
|
||||
@@ -410,8 +391,6 @@ export function ProfileFeedScreenInner({
|
||||
onPressShare,
|
||||
t,
|
||||
isPending,
|
||||
isFeedSubmittable,
|
||||
openComposer,
|
||||
])
|
||||
|
||||
return (
|
||||
@@ -442,7 +421,15 @@ export function ProfileFeedScreenInner({
|
||||
{hasSession && (
|
||||
<FAB
|
||||
testID="composeFAB"
|
||||
onPress={() => openComposer({})}
|
||||
onPress={() => {
|
||||
let initFeeds
|
||||
if (feedInfo.creatorDid === currentAccount?.did) {
|
||||
initFeeds = [feedInfo.uri]
|
||||
}
|
||||
openComposer({
|
||||
initFeeds,
|
||||
})
|
||||
}}
|
||||
icon={
|
||||
<ComposeIcon2
|
||||
strokeWidth={1.5}
|
||||
|
||||
@@ -23,6 +23,7 @@ import {useFetchHandle} from '#/state/queries/handle'
|
||||
import {useUnreadMessageCount} from '#/state/queries/messages/list-converations'
|
||||
import {useUnreadNotifications} from '#/state/queries/notifications/unread'
|
||||
import {useProfileQuery} from '#/state/queries/profile'
|
||||
import {useAgent} from '#/state/session'
|
||||
import {useSession} from '#/state/session'
|
||||
import {useComposerControls} from '#/state/shell/composer'
|
||||
import {Link} from '#/view/com/util/Link'
|
||||
@@ -261,12 +262,16 @@ function ComposeBtn() {
|
||||
const {isTablet} = useWebMediaQueries()
|
||||
const [isFetchingHandle, setIsFetchingHandle] = React.useState(false)
|
||||
const fetchHandle = useFetchHandle()
|
||||
const agent = useAgent()
|
||||
|
||||
const getProfileHandle = async () => {
|
||||
const routes = getState()?.routes
|
||||
const currentRoute = routes?.[routes?.length - 1]
|
||||
|
||||
if (currentRoute?.name === 'Profile') {
|
||||
if (
|
||||
currentRoute?.name === 'Profile' ||
|
||||
currentRoute?.name === 'ProfileFeed'
|
||||
) {
|
||||
let handle: string | undefined = (
|
||||
currentRoute.params as CommonNavigatorParams['Profile']
|
||||
).name
|
||||
@@ -282,12 +287,7 @@ function ComposeBtn() {
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!handle ||
|
||||
handle === currentAccount?.handle ||
|
||||
isInvalidHandle(handle)
|
||||
)
|
||||
return undefined
|
||||
if (!handle || isInvalidHandle(handle)) return undefined
|
||||
|
||||
return handle
|
||||
}
|
||||
@@ -295,8 +295,42 @@ function ComposeBtn() {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const onPressCompose = async () =>
|
||||
openComposer({mention: await getProfileHandle()})
|
||||
const getFeedUris = async (handle: string | undefined) => {
|
||||
if (!handle) return undefined
|
||||
|
||||
const did = (await agent.resolveHandle({handle: handle})).data.did
|
||||
|
||||
const routes = getState()?.routes
|
||||
const currentRoute = routes?.[routes?.length - 1]
|
||||
|
||||
if (currentRoute?.name === 'ProfileFeed') {
|
||||
let rkey: string | undefined = (
|
||||
currentRoute.params as CommonNavigatorParams['ProfileFeed']
|
||||
).rkey
|
||||
|
||||
return [`at://${did}/app.bsky.feed.generator/${rkey}`]
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
const onPressCompose = async () => {
|
||||
const handle = await getProfileHandle()
|
||||
const routes = getState()?.routes
|
||||
const currentRoute = routes?.[routes?.length - 1]
|
||||
let mention =
|
||||
handle !== currentAccount?.handle && currentRoute?.name === 'Profile'
|
||||
? handle
|
||||
: undefined
|
||||
let initFeeds =
|
||||
handle === currentAccount?.handle && currentRoute?.name === 'ProfileFeed'
|
||||
? await getFeedUris(handle)
|
||||
: undefined
|
||||
openComposer({
|
||||
mention,
|
||||
initFeeds,
|
||||
})
|
||||
}
|
||||
|
||||
if (isTablet) {
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user