Update the view after a post is created

This commit is contained in:
Paul Frazee 2022-10-04 11:33:32 -05:00
parent 0aaa406b17
commit 236c908058
9 changed files with 79 additions and 9 deletions

View file

@ -16,7 +16,13 @@ const WARNING_TEXT_LENGTH = 200
const DANGER_TEXT_LENGTH = 255
export const snapPoints = ['100%']
export function Component({replyTo}: {replyTo?: string}) {
export function Component({
replyTo,
onPost,
}: {
replyTo?: string
onPost?: () => void
}) {
const store = useStores()
const [error, setError] = useState('')
const [text, setText] = useState('')
@ -72,6 +78,7 @@ export function Component({replyTo}: {replyTo?: string}) {
)
return
}
onPost?.()
store.shell.closeModal()
Toast.show(`Your ${replyTo ? 'reply' : 'post'} has been published`, {
duration: Toast.durations.LONG,

View file

@ -70,7 +70,11 @@ export const PostThread = observer(function PostThread({uri}: {uri: string}) {
// =
const posts = view.thread ? Array.from(flattenThread(view.thread)) : []
const renderItem = ({item}: {item: PostThreadViewPostModel}) => (
<PostThreadItem item={item} onPressShare={onPressShare} />
<PostThreadItem
item={item}
onPressShare={onPressShare}
onPostReply={onRefresh}
/>
)
return (
<FlatList

View file

@ -20,9 +20,11 @@ const PARENT_REPLY_LINE_LENGTH = 8
export const PostThreadItem = observer(function PostThreadItem({
item,
onPressShare,
onPostReply,
}: {
item: PostThreadViewPostModel
onPressShare: (_uri: string) => void
onPostReply: () => void
}) {
const store = useStores()
const record = item.record as unknown as PostType.Record
@ -47,7 +49,9 @@ export const PostThreadItem = observer(function PostThreadItem({
const repostsTitle = 'Reposts of this post'
const onPressReply = () => {
store.shell.openModal(new ComposePostModel(item.uri))
store.shell.openModal(
new ComposePostModel({replyTo: item.uri, onPost: onPostReply}),
)
}
const onPressToggleRepost = () => {
item

View file

@ -72,7 +72,7 @@ export const Post = observer(function Post({uri}: {uri: string}) {
replyHref = `/profile/${urip.hostname}/post/${urip.recordKey}`
}
const onPressReply = () => {
store.shell.openModal(new ComposePostModel(item.uri))
store.shell.openModal(new ComposePostModel({replyTo: item.uri}))
}
const onPressToggleRepost = () => {
item

View file

@ -40,7 +40,7 @@ export const FeedItem = observer(function FeedItem({
}, [record.reply])
const onPressReply = () => {
store.shell.openModal(new ComposePostModel(item.uri))
store.shell.openModal(new ComposePostModel({replyTo: item.uri}))
}
const onPressToggleRepost = () => {
item

View file

@ -31,7 +31,10 @@ export const Home = observer(function Home({visible}: ScreenParams) {
}, [visible, store])
const onComposePress = () => {
store.shell.openModal(new ComposePostModel())
store.shell.openModal(new ComposePostModel({onPost: onCreatePost}))
}
const onCreatePost = () => {
feedView?.loadLatest()
}
return (