73-post-embeds (#253)

* update api to 0.1.3

* add repost modal with reposting functionality

* add quote post UI

* allow creation and view of quote posts

* Validate the post record before rendering a quote post

* Use createdAt in quote posts for now

* add web modal support

* Tune the quote post rendering

* Make did and declarationCid optional in postmeta

* Make did and declarationCid optional in postmeta

* dont allow image or link preview if quote post

* Handle no-text quote posts

* Tune the repost modal

* Tweak composer post text

* Fix lint

---------

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
This commit is contained in:
Ansh 2023-03-02 16:09:48 -08:00 committed by GitHub
parent f539659ac8
commit 75174a6c37
18 changed files with 392 additions and 69 deletions

View file

@ -26,6 +26,7 @@ import {
} from 'lib/icons'
import {s, colors} from 'lib/styles'
import {useTheme} from 'lib/ThemeContext'
import {useStores} from 'state/index'
interface PostCtrlsOpts {
itemUri: string
@ -33,6 +34,13 @@ interface PostCtrlsOpts {
itemHref: string
itemTitle: string
isAuthor: boolean
author: {
handle: string
displayName: string
avatar: string
}
text: string
indexedAt: string
big?: boolean
style?: StyleProp<ViewStyle>
replyCount?: number
@ -86,6 +94,7 @@ function ctrlAnimStyle(interp: Animated.Value) {
*/
export function PostCtrls(opts: PostCtrlsOpts) {
const store = useStores()
const theme = useTheme()
const defaultCtrlColor = React.useMemo(
() => ({
@ -98,7 +107,8 @@ export function PostCtrls(opts: PostCtrlsOpts) {
// DISABLED see #135
// const repostRef = React.useRef<TriggerableAnimatedRef | null>(null)
// const likeRef = React.useRef<TriggerableAnimatedRef | null>(null)
const onPressToggleRepostWrapper = () => {
const onRepost = () => {
store.shell.closeModal()
if (!opts.isReposted) {
ReactNativeHapticFeedback.trigger('impactMedium')
setRepostMod(1)
@ -122,6 +132,30 @@ export function PostCtrls(opts: PostCtrlsOpts) {
.then(() => setRepostMod(0))
}
}
const onQuote = () => {
store.shell.closeModal()
store.shell.openComposer({
quote: {
uri: opts.itemUri,
cid: opts.itemCid,
text: opts.text,
author: opts.author,
indexedAt: opts.indexedAt,
},
})
ReactNativeHapticFeedback.trigger('impactMedium')
}
const onPressToggleRepostWrapper = () => {
store.shell.openModal({
name: 'repost',
onRepost: onRepost,
onQuote: onQuote,
isReposted: opts.isReposted,
})
}
const onPressToggleUpvoteWrapper = () => {
if (!opts.isUpvoted) {
ReactNativeHapticFeedback.trigger('impactMedium')