mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
using single conversation hook instance
This commit is contained in:
parent
896a2bc691
commit
8245717ba4
@ -19,6 +19,7 @@ import { Details, DetailsHeader, DetailsBody } from './details/Details';
|
||||
import { Conversation, ConversationHeader, ConversationBody } from './conversation/Conversation';
|
||||
import { Welcome } from './welcome/Welcome';
|
||||
import { ChannelsTitle, ChannelsBody, Channels } from './channels/Channels';
|
||||
import { useConversation } from './conversation/useConversation.hook';
|
||||
import { useChannels } from './channels/useChannels.hook';
|
||||
import { CommonActions } from '@react-navigation/native';
|
||||
import { ConversationContext } from 'context/ConversationContext';
|
||||
@ -66,11 +67,12 @@ export function Session() {
|
||||
navigation.goBack();
|
||||
}
|
||||
|
||||
const conversation = useConversation();
|
||||
const channels = useChannels();
|
||||
const conversation = useContext(ConversationContext);
|
||||
const conversationContext = useContext(ConversationContext);
|
||||
|
||||
useEffect(() => {
|
||||
conversation.actions.setChannel(selectedConversation);
|
||||
conversationContext.actions.setChannel(selectedConversation);
|
||||
}, [selectedConversation]);
|
||||
|
||||
return (
|
||||
@ -88,9 +90,10 @@ export function Session() {
|
||||
<ConversationStack.Screen name="conversation" options={{
|
||||
headerStyle: { backgroundColor: Colors.titleBackground },
|
||||
headerBackTitleVisible: false,
|
||||
headerTitle: (props) => <ConversationHeader channel={selectedConversation} closeConversation={clearConversation} openDetails={setDetail} />
|
||||
headerTitle: (props) => <ConversationHeader channel={selectedConversation} closeConversation={clearConversation} openDetails={setDetail}
|
||||
state={conversation.state} actions={conversation.actions} />
|
||||
}}>
|
||||
{(props) => <ConversationBody channel={selectedConversation} />}
|
||||
{(props) => <ConversationBody channel={selectedConversation} state={conversation.state} actions={conversation.actions} />}
|
||||
</ConversationStack.Screen>
|
||||
<ConversationStack.Screen name="details" options={{
|
||||
headerStyle: { backgroundColor: Colors.titleBackground },
|
||||
|
@ -10,9 +10,8 @@ import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import { AddTopic } from './addTopic/AddTopic';
|
||||
import { TopicItem } from './topicItem/TopicItem';
|
||||
|
||||
export function ConversationHeader({ closeConversation, openDetails }) {
|
||||
export function ConversationHeader({ closeConversation, openDetails, state, actions }) {
|
||||
const navigation = useNavigation();
|
||||
const { state, actions } = useConversation();
|
||||
|
||||
const setDetails = () => {
|
||||
openDetails(navigation);
|
||||
@ -39,9 +38,7 @@ export function ConversationHeader({ closeConversation, openDetails }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function ConversationBody() {
|
||||
const { state, actions } = useConversation();
|
||||
|
||||
export function ConversationBody({ state, actions }) {
|
||||
const ref = useRef();
|
||||
|
||||
useEffect(() => {
|
||||
@ -172,7 +169,7 @@ export function Conversation({ closeConversation, openDetails }) {
|
||||
</TouchableOpacity>
|
||||
</SafeAreaView>
|
||||
<SafeAreaView edges={['bottom']} style={styles.body}>
|
||||
<ConversationBody />
|
||||
<ConversationBody state={state} actions={actions} />
|
||||
</SafeAreaView>
|
||||
</View>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user