Composer update (react-query refactor) (#1899)

* Move composer state to a context

* Rework composer to use RQ

---------

Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
Paul Frazee 2023-11-14 10:41:55 -08:00 committed by GitHub
parent c687172de9
commit 0a26e78dcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 269 additions and 239 deletions

View file

@ -2,30 +2,21 @@ import React, {useEffect} from 'react'
import {observer} from 'mobx-react-lite'
import {Animated, Easing, Platform, StyleSheet, View} from 'react-native'
import {ComposePost} from '../com/composer/Composer'
import {ComposerOpts} from 'state/models/ui/shell'
import {useComposerState} from 'state/shell/composer'
import {useAnimatedValue} from 'lib/hooks/useAnimatedValue'
import {usePalette} from 'lib/hooks/usePalette'
export const Composer = observer(function ComposerImpl({
active,
winHeight,
replyTo,
onPost,
quote,
mention,
}: {
active: boolean
winHeight: number
replyTo?: ComposerOpts['replyTo']
onPost?: ComposerOpts['onPost']
quote?: ComposerOpts['quote']
mention?: ComposerOpts['mention']
}) {
const state = useComposerState()
const pal = usePalette('default')
const initInterp = useAnimatedValue(0)
useEffect(() => {
if (active) {
if (state) {
Animated.timing(initInterp, {
toValue: 1,
duration: 300,
@ -35,7 +26,7 @@ export const Composer = observer(function ComposerImpl({
} else {
initInterp.setValue(0)
}
}, [initInterp, active])
}, [initInterp, state])
const wrapperAnimStyle = {
transform: [
{
@ -50,7 +41,7 @@ export const Composer = observer(function ComposerImpl({
// rendering
// =
if (!active) {
if (!state) {
return <View />
}
@ -60,10 +51,10 @@ export const Composer = observer(function ComposerImpl({
aria-modal
accessibilityViewIsModal>
<ComposePost
replyTo={replyTo}
onPost={onPost}
quote={quote}
mention={mention}
replyTo={state.replyTo}
onPost={state.onPost}
quote={state.quote}
mention={state.mention}
/>
</Animated.View>
)