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 { Conversation, ConversationHeader, ConversationBody } from './conversation/Conversation';
|
||||||
import { Welcome } from './welcome/Welcome';
|
import { Welcome } from './welcome/Welcome';
|
||||||
import { ChannelsTitle, ChannelsBody, Channels } from './channels/Channels';
|
import { ChannelsTitle, ChannelsBody, Channels } from './channels/Channels';
|
||||||
|
import { useConversation } from './conversation/useConversation.hook';
|
||||||
import { useChannels } from './channels/useChannels.hook';
|
import { useChannels } from './channels/useChannels.hook';
|
||||||
import { CommonActions } from '@react-navigation/native';
|
import { CommonActions } from '@react-navigation/native';
|
||||||
import { ConversationContext } from 'context/ConversationContext';
|
import { ConversationContext } from 'context/ConversationContext';
|
||||||
@ -66,11 +67,12 @@ export function Session() {
|
|||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const conversation = useConversation();
|
||||||
const channels = useChannels();
|
const channels = useChannels();
|
||||||
const conversation = useContext(ConversationContext);
|
const conversationContext = useContext(ConversationContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
conversation.actions.setChannel(selectedConversation);
|
conversationContext.actions.setChannel(selectedConversation);
|
||||||
}, [selectedConversation]);
|
}, [selectedConversation]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -88,9 +90,10 @@ export function Session() {
|
|||||||
<ConversationStack.Screen name="conversation" options={{
|
<ConversationStack.Screen name="conversation" options={{
|
||||||
headerStyle: { backgroundColor: Colors.titleBackground },
|
headerStyle: { backgroundColor: Colors.titleBackground },
|
||||||
headerBackTitleVisible: false,
|
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>
|
||||||
<ConversationStack.Screen name="details" options={{
|
<ConversationStack.Screen name="details" options={{
|
||||||
headerStyle: { backgroundColor: Colors.titleBackground },
|
headerStyle: { backgroundColor: Colors.titleBackground },
|
||||||
|
@ -10,9 +10,8 @@ import { SafeAreaView } from 'react-native-safe-area-context';
|
|||||||
import { AddTopic } from './addTopic/AddTopic';
|
import { AddTopic } from './addTopic/AddTopic';
|
||||||
import { TopicItem } from './topicItem/TopicItem';
|
import { TopicItem } from './topicItem/TopicItem';
|
||||||
|
|
||||||
export function ConversationHeader({ closeConversation, openDetails }) {
|
export function ConversationHeader({ closeConversation, openDetails, state, actions }) {
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
const { state, actions } = useConversation();
|
|
||||||
|
|
||||||
const setDetails = () => {
|
const setDetails = () => {
|
||||||
openDetails(navigation);
|
openDetails(navigation);
|
||||||
@ -39,9 +38,7 @@ export function ConversationHeader({ closeConversation, openDetails }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ConversationBody() {
|
export function ConversationBody({ state, actions }) {
|
||||||
const { state, actions } = useConversation();
|
|
||||||
|
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -172,7 +169,7 @@ export function Conversation({ closeConversation, openDetails }) {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
<SafeAreaView edges={['bottom']} style={styles.body}>
|
<SafeAreaView edges={['bottom']} style={styles.body}>
|
||||||
<ConversationBody />
|
<ConversationBody state={state} actions={actions} />
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user