From 0a26e78dcbbf48dad5daae73b210e236d706b22c Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 14 Nov 2023 10:41:55 -0800 Subject: Composer update (react-query refactor) (#1899) * Move composer state to a context * Rework composer to use RQ --------- Co-authored-by: Eric Bailey --- src/view/shell/Composer.tsx | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'src/view/shell/Composer.tsx') diff --git a/src/view/shell/Composer.tsx b/src/view/shell/Composer.tsx index 219a594ed..d37ff4fb7 100644 --- a/src/view/shell/Composer.tsx +++ b/src/view/shell/Composer.tsx @@ -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 } @@ -60,10 +51,10 @@ export const Composer = observer(function ComposerImpl({ aria-modal accessibilityViewIsModal> ) -- cgit 1.4.1