mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 20:49:16 +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 { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
|
||||||
import { NavigationContainer } from '@react-navigation/native';
|
import { NavigationContainer } from '@react-navigation/native';
|
||||||
import { ConversationContextProvider } from 'context/ConversationContext';
|
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() {
|
export default function App() {
|
||||||
|
|
||||||
|
@ -152,6 +152,7 @@ export function useConversationContext() {
|
|||||||
// update revision
|
// update revision
|
||||||
revision.current = channelItem.revision;
|
revision.current = channelItem.revision;
|
||||||
if (curView == setView.current) {
|
if (curView == setView.current) {
|
||||||
|
console.log("update:", topics.current.size);
|
||||||
updateState({ topics: topics.current });
|
updateState({ topics: topics.current });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ export function ConversationBody({ channel }) {
|
|||||||
<FlatList style={styles.topics}
|
<FlatList style={styles.topics}
|
||||||
data={state.topics}
|
data={state.topics}
|
||||||
inverted={true}
|
inverted={true}
|
||||||
renderItem={({item}) => <View style={{ height: item.id }}><Text>ITEM { item.id }</Text></View>}
|
renderItem={({item}) => <View><Text>ITEM { item?.detail?.data }</Text></View>}
|
||||||
keyExtractor={item => item.id}
|
keyExtractor={item => item.topicId}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,20 @@ export function useConversation(cardId, channelId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { topics, subject, logo } = conversation.state;
|
const { subject, logo, topics } = conversation.state;
|
||||||
updateState({ topics, subject, logo });
|
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]);
|
}, [conversation]);
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
|
Loading…
Reference in New Issue
Block a user