From 2e7e5a6322c8b37e5ebd17a1dfb685136fa20159 Mon Sep 17 00:00:00 2001 From: balzack Date: Sun, 29 Dec 2024 22:25:45 -0800 Subject: [PATCH] rendering activity indicator --- .../src/conversation/Conversation.styled.ts | 21 +++++- .../mobile/src/conversation/Conversation.tsx | 69 +++++++++++-------- .../src/conversation/useConversation.hook.ts | 3 +- 3 files changed, 63 insertions(+), 30 deletions(-) diff --git a/app/client/mobile/src/conversation/Conversation.styled.ts b/app/client/mobile/src/conversation/Conversation.styled.ts index 2ad64134..34226c9d 100644 --- a/app/client/mobile/src/conversation/Conversation.styled.ts +++ b/app/client/mobile/src/conversation/Conversation.styled.ts @@ -6,13 +6,32 @@ export const styles = StyleSheet.create({ display: 'flex', flexDirection: 'column', height: '100%', + minHeight: 0, }, messages: { paddingBottom: 64, }, thread: { - width: '100%', + display: 'flex', flexGrow: 1, + minHeight: 0, + height: '50%', + width: '100%', + alignItems: 'center', + justifyContent: 'center', + }, + more: { + paddingTop: 16, + position: 'absolute', + top: 0, + }, + loading: { + position: 'absolute', + }, + empty: { + position: 'absolute', + fontSize: 20, + color: Colors.placeholder, }, add: { height: 72, diff --git a/app/client/mobile/src/conversation/Conversation.tsx b/app/client/mobile/src/conversation/Conversation.tsx index b1e53538..6b1e65ba 100644 --- a/app/client/mobile/src/conversation/Conversation.tsx +++ b/app/client/mobile/src/conversation/Conversation.tsx @@ -4,6 +4,7 @@ import {styles} from './Conversation.styled'; import {useConversation} from './useConversation.hook'; import {Message} from '../message/Message'; import {Icon, Text, IconButton, Divider} from 'react-native-paper'; +import { ActivityIndicator } from 'react-native-paper'; const SCROLL_THRESHOLD = 16; @@ -91,33 +92,47 @@ export function Conversation({close}: {close: ()=>void}) { {close && } - { - const { host } = state; - const card = state.cards.get(item.guid) || null; - const profile = state.profile?.guid === item.guid ? state.profile : null; - return ( - - ) - }} - keyExtractor={topic => (topic.topicId)} - /> + + { + const { host } = state; + const card = state.cards.get(item.guid) || null; + const profile = state.profile?.guid === item.guid ? state.profile : null; + return ( + + ) + }} + keyExtractor={topic => (topic.topicId)} + /> + { state.loaded && state.topics.length === 0 && ( + {state.strings.noMessages} + )} + { !state.loaded && ( + + + + )} + { more && ( + + + + )} + thread.current.scrollToEnd()}> ADD diff --git a/app/client/mobile/src/conversation/useConversation.hook.ts b/app/client/mobile/src/conversation/useConversation.hook.ts index f5a208b2..6bf1002c 100644 --- a/app/client/mobile/src/conversation/useConversation.hook.ts +++ b/app/client/mobile/src/conversation/useConversation.hook.ts @@ -33,7 +33,6 @@ export function useConversation() { focus: null as Focus | null, layout: null, topics: [] as Topic[], - topicCount: 0, loaded: false, loadingMore: false, profile: null as Profile | null, @@ -102,7 +101,7 @@ export function useConversation() { return 0; } }); - updateState({ topics: sorted, topicCount: topics.length, loaded: true }); + updateState({ topics: sorted, loaded: true }); } } const setCards = (cards: Card[]) => {