Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3515073
D14143.id46443.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D14143.id46443.diff
View Options
diff --git a/native/chat/chat-thread-list-utils.js b/native/chat/chat-thread-list-utils.js
--- a/native/chat/chat-thread-list-utils.js
+++ b/native/chat/chat-thread-list-utils.js
@@ -9,17 +9,24 @@
} from './chat-thread-list-item.react.js';
import type { Item } from './chat-thread-list.react.js';
import { sidebarHeight } from './sidebar-item.react.js';
+import { listLoadingIndicatorHeight } from '../components/list-loading-indicator-utils.js';
function keyExtractor(item: Item): string {
if (item.type === 'chatThreadItem') {
return item.threadInfo.id;
} else if (item.type === 'empty') {
return 'empty';
+ } else if (item.type === 'loader') {
+ return 'loader';
}
return 'search';
}
function itemHeight(item: Item): number {
+ if (item.type === 'loader') {
+ return listLoadingIndicatorHeight;
+ }
+
if (item.type === 'search') {
return Platform.OS === 'ios' ? 54.5 : 55;
}
diff --git a/native/chat/chat-thread-list.react.js b/native/chat/chat-thread-list.react.js
--- a/native/chat/chat-thread-list.react.js
+++ b/native/chat/chat-thread-list.react.js
@@ -45,6 +45,7 @@
ChatTopTabsNavigationProp,
} from './chat.react.js';
import { useNavigateToThread } from './message-list-types.js';
+import ListLoadingIndicator from '../components/list-loading-indicator.react.js';
import {
BackgroundChatThreadListRouteName,
HomeChatThreadListRouteName,
@@ -69,7 +70,8 @@
export type Item =
| ChatThreadItem
| { +type: 'search', +searchText: string }
- | { +type: 'empty', +emptyItem: React.ComponentType<{}> };
+ | { +type: 'empty', +emptyItem: React.ComponentType<{}> }
+ | { +type: 'loader' };
type BaseProps = {
+navigation:
@@ -270,6 +272,13 @@
const renderItem = React.useCallback(
(row: { item: Item, ... }) => {
const item = row.item;
+ if (item.type === 'loader') {
+ return (
+ <View style={styles.listLoadingIndicator}>
+ <ListLoadingIndicator />
+ </View>
+ );
+ }
if (item.type === 'search') {
return searchItem;
}
@@ -293,6 +302,7 @@
onSwipeableWillOpen,
openedSwipeableID,
searchItem,
+ styles.listLoadingIndicator,
],
);
@@ -389,12 +399,19 @@
const viewerID = loggedInUserInfo?.id;
const extraData = `${viewerID || ''} ${openedSwipeableID}`;
+ const finalListData = React.useMemo(() => {
+ if (partialListData.length === listData.length) {
+ return partialListData;
+ }
+ return [...partialListData, { type: 'loader' }];
+ }, [partialListData, listData.length]);
+
const chatThreadList = React.useMemo(
() => (
<View style={styles.container}>
{fixedSearch}
<FlatList
- data={partialListData}
+ data={finalListData}
renderItem={renderItem}
keyExtractor={keyExtractor}
getItemLayout={getItemLayout}
@@ -419,7 +436,7 @@
indicatorStyle,
onEndReached,
onScroll,
- partialListData,
+ finalListData,
renderItem,
scrollEnabled,
styles.container,
@@ -518,6 +535,9 @@
flex: 1,
backgroundColor: 'listBackground',
},
+ listLoadingIndicator: {
+ flex: 1,
+ },
};
export default ChatThreadList;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 7:23 AM (18 h, 3 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2691455
Default Alt Text
D14143.id46443.diff (3 KB)
Attached To
Mode
D14143: [native] Add loading indicator at the bottom of ChatThreadList
Attached
Detach File
Event Timeline
Log In to Comment