This commit is contained in:
Eric Bailey
2024-10-23 12:35:04 -05:00
parent 7a14f82b03
commit fa9c020047
4 changed files with 38 additions and 6 deletions
+4
View File
@@ -46,6 +46,7 @@ export type FeedSourceFeedInfo = {
name: string name: string
params: Record<string, string> params: Record<string, string>
} }
did: string
cid: string cid: string
avatar: string | undefined avatar: string | undefined
displayName: string displayName: string
@@ -65,6 +66,7 @@ export type FeedSourceListInfo = {
name: string name: string
params: Record<string, string> params: Record<string, string>
} }
did: unknown
cid: string cid: string
avatar: string | undefined avatar: string | undefined
displayName: string displayName: string
@@ -99,6 +101,7 @@ export function hydrateFeedGenerator(
type: 'feed', type: 'feed',
uri: view.uri, uri: view.uri,
feedDescriptor: `feedgen|${view.uri}`, feedDescriptor: `feedgen|${view.uri}`,
did: view.did,
cid: view.cid, cid: view.cid,
route: { route: {
href, href,
@@ -136,6 +139,7 @@ export function hydrateList(view: AppBskyGraphDefs.ListView): FeedSourceInfo {
name: route[0], name: route[0],
params: route[1], params: route[1],
}, },
did: view.did,
cid: view.cid, cid: view.cid,
avatar: view.avatar, avatar: view.avatar,
description: new RichText({ description: new RichText({
+11 -5
View File
@@ -141,8 +141,10 @@ export const ComposePost = ({
imageUris: initImageUris, imageUris: initImageUris,
videoUri: initVideoUri, videoUri: initVideoUri,
cancelRef, cancelRef,
initFeeds,
}: Props & { }: Props & {
cancelRef?: React.RefObject<CancelRef> cancelRef?: React.RefObject<CancelRef>
initFeeds?: string[]
}) => { }) => {
const {currentAccount} = useSession() const {currentAccount} = useSession()
const agent = useAgent() const agent = useAgent()
@@ -175,7 +177,7 @@ export const ComposePost = ({
initText, initText,
initMention, initMention,
initOutlineTags: [], initOutlineTags: [],
initFeeds: [], initFeeds: initFeeds || [],
}, },
createComposerState, createComposerState,
) )
@@ -537,6 +539,7 @@ export const ComposePost = ({
const [showOutlineTags, setShowOutlineTags] = useState(false) const [showOutlineTags, setShowOutlineTags] = useState(false)
const outlineTagsVisible = showOutlineTags || draft.tags.length > 0 const outlineTagsVisible = showOutlineTags || draft.tags.length > 0
const [showFeeds, setShowFeeds] = useState(false) const [showFeeds, setShowFeeds] = useState(false)
const feedsAreVisible = showFeeds || draft.feeds.length > 0
const { const {
scrollHandler, scrollHandler,
@@ -793,7 +796,7 @@ export const ComposePost = ({
</View> </View>
)} )}
{showFeeds && ( {feedsAreVisible && (
<View style={[a.px_lg]}> <View style={[a.px_lg]}>
<Divider /> <Divider />
<View style={[a.flex_row, a.gap_xs, a.pt_sm, a.pb_md]}> <View style={[a.flex_row, a.gap_xs, a.pt_sm, a.pb_md]}>
@@ -806,7 +809,10 @@ export const ComposePost = ({
<FeedsIcon size="md" /> <FeedsIcon size="md" />
</View> </View>
<View style={[a.flex_1]}> <View style={[a.flex_1]}>
<FeedsSelector onChangeFeeds={onChangeFeeds} /> <FeedsSelector
initialFeeds={draft.feeds}
onChangeFeeds={onChangeFeeds}
/>
</View> </View>
</View> </View>
</View> </View>
@@ -863,9 +869,9 @@ export const ComposePost = ({
</Button> </Button>
)} )}
{!showFeeds && ( {!feedsAreVisible && (
<Button <Button
label={_(msg`Add tags`)} label={_(msg`Add feeds to submit to`)}
size="small" size="small"
variant="solid" variant="solid"
color="secondary" color="secondary"
+22 -1
View File
@@ -51,10 +51,11 @@ import {Text} from '#/view/com/util/text/Text'
import * as Toast from '#/view/com/util/Toast' import * as Toast from '#/view/com/util/Toast'
import {CenteredView} from '#/view/com/util/Views' import {CenteredView} from '#/view/com/util/Views'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
import {Button as NewButton, ButtonText} from '#/components/Button' import {Button as NewButton, ButtonIcon, ButtonText} from '#/components/Button'
import {useRichText} from '#/components/hooks/useRichText' import {useRichText} from '#/components/hooks/useRichText'
import {ArrowOutOfBox_Stroke2_Corner0_Rounded as Share} from '#/components/icons/ArrowOutOfBox' import {ArrowOutOfBox_Stroke2_Corner0_Rounded as Share} from '#/components/icons/ArrowOutOfBox'
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo' import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
import {EditBig_Stroke2_Corner0_Rounded as EditBig} from '#/components/icons/EditBig'
import { import {
Heart2_Filled_Stroke2_Corner0_Rounded as HeartFilled, Heart2_Filled_Stroke2_Corner0_Rounded as HeartFilled,
Heart2_Stroke2_Corner0_Rounded as HeartOutline, Heart2_Stroke2_Corner0_Rounded as HeartOutline,
@@ -266,6 +267,9 @@ export function ProfileFeedScreenInner({
}, },
[feedSectionRef], [feedSectionRef],
) )
const isFeedSubmittable =
feedInfo.creatorDid === currentAccount?.did &&
feedInfo.did === 'did:web:feeed.club'
const renderHeader = useCallback(() => { const renderHeader = useCallback(() => {
return ( return (
@@ -283,6 +287,21 @@ export function ProfileFeedScreenInner({
} }
avatarType="algo"> avatarType="algo">
<View style={[a.flex_row, a.align_center, a.gap_sm]}> <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 && ( {feedInfo && hasSession && (
<NewButton <NewButton
testID={isPinned ? 'unpinBtn' : 'pinBtn'} testID={isPinned ? 'unpinBtn' : 'pinBtn'}
@@ -391,6 +410,8 @@ export function ProfileFeedScreenInner({
onPressShare, onPressShare,
t, t,
isPending, isPending,
isFeedSubmittable,
openComposer,
]) ])
return ( return (
+1
View File
@@ -100,6 +100,7 @@ function Inner({state}: {state: ComposerOpts}) {
openEmojiPicker={onOpenPicker} openEmojiPicker={onOpenPicker}
text={state.text} text={state.text}
imageUris={state.imageUris} imageUris={state.imageUris}
initFeeds={state.initFeeds}
/> />
</View> </View>
<EmojiPicker state={pickerState} close={onClosePicker} /> <EmojiPicker state={pickerState} close={onClosePicker} />