mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
rendering topics
This commit is contained in:
parent
0251b648ef
commit
9dce08ff64
@ -15,6 +15,10 @@ import { ChannelContextProvider } from 'context/ChannelContext';
|
||||
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
|
||||
import { NavigationContainer } from '@react-navigation/native';
|
||||
import { ConversationContextProvider } from 'context/ConversationContext';
|
||||
import { LogBox } from 'react-native';
|
||||
|
||||
// silence warning: Sending `onAnimatedValueUpdate` with no listeners registered
|
||||
//LogBox.ignoreLogs(['Sending']);
|
||||
|
||||
export default function App() {
|
||||
|
||||
|
@ -152,6 +152,7 @@ export function useConversationContext() {
|
||||
// update revision
|
||||
revision.current = channelItem.revision;
|
||||
if (curView == setView.current) {
|
||||
console.log("update:", topics.current.size);
|
||||
updateState({ topics: topics.current });
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,8 @@ export function ConversationBody({ channel }) {
|
||||
<FlatList style={styles.topics}
|
||||
data={state.topics}
|
||||
inverted={true}
|
||||
renderItem={({item}) => <View style={{ height: item.id }}><Text>ITEM { item.id }</Text></View>}
|
||||
keyExtractor={item => item.id}
|
||||
renderItem={({item}) => <View><Text>ITEM { item?.detail?.data }</Text></View>}
|
||||
keyExtractor={item => item.topicId}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -16,8 +16,20 @@ export function useConversation(cardId, channelId) {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const { topics, subject, logo } = conversation.state;
|
||||
updateState({ topics, subject, logo });
|
||||
const { subject, logo, topics } = conversation.state;
|
||||
const items = Array.from(topics.values());
|
||||
const sorted = items.sort((a, b) => {
|
||||
const aTimestamp = a?.detail?.created;
|
||||
const bTimestamp = b?.detail?.created;
|
||||
if(aTimestamp === bTimestamp) {
|
||||
return 0;
|
||||
}
|
||||
if(aTimestamp == null || aTimestamp < bTimestamp) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
});
|
||||
updateState({ topics, subject, logo, topics: sorted });
|
||||
}, [conversation]);
|
||||
|
||||
const actions = {
|
||||
|
Loading…
Reference in New Issue
Block a user