Skip to content

Commit 41423b6

Browse files
Merge pull request #317 from reown-com/fix/ui-fixes
fix: loader issue activity tab
2 parents 728ec72 + 2ca82f0 commit 41423b6

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

packages/scaffold/src/partials/w3m-account-activity/index.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useCallback, useEffect, useMemo, useState } from 'react';
21
import { useSnapshot } from 'valtio';
2+
import { useCallback, useEffect, useMemo, useState } from 'react';
33
import { ScrollView, View, type StyleProp, type ViewStyle, RefreshControl } from 'react-native';
44
import {
55
FlexView,
@@ -30,6 +30,7 @@ interface Props {
3030
export function AccountActivity({ style }: Props) {
3131
const Theme = useTheme();
3232
const [refreshing, setRefreshing] = useState(false);
33+
const [initialLoad, setInitialLoad] = useState(true);
3334
const { loading, transactions, next } = useSnapshot(TransactionsController.state);
3435
const { caipNetwork } = useSnapshot(NetworkController.state);
3536
const networkImage = AssetUtil.getNetworkImage(caipNetwork);
@@ -62,23 +63,29 @@ export function AccountActivity({ style }: Props) {
6263
if (!TransactionsController.state.transactions.length) {
6364
TransactionsController.fetchTransactions(AccountController.state.address, true);
6465
}
66+
// Set initial load to false after first fetch
67+
const timer = setTimeout(() => setInitialLoad(false), 100);
68+
69+
return () => clearTimeout(timer);
6570
}, []);
6671

67-
if (loading && !transactions.length) {
72+
// Show loading spinner during initial load or when loading with no transactions
73+
if ((initialLoad || loading) && !transactions.length) {
6874
return (
6975
<FlexView style={[styles.placeholder, style]} alignItems="center" justifyContent="center">
7076
<LoadingSpinner />
7177
</FlexView>
7278
);
7379
}
7480

75-
if (!Object.keys(transactionsByYear).length) {
81+
// Only show placeholder when we're not in initial load or loading state
82+
if (!Object.keys(transactionsByYear).length && !loading && !initialLoad) {
7683
return (
7784
<Placeholder
7885
icon="swapHorizontal"
7986
title="No activity yet"
8087
description="Your next transactions will appear here"
81-
style={style}
88+
style={[styles.placeholder, style]}
8289
/>
8390
);
8491
}
@@ -150,14 +157,14 @@ export function AccountActivity({ style }: Props) {
150157
))}
151158
</View>
152159
))}
153-
{(next || loading) && (
160+
{(next || loading) && !refreshing && (
154161
<FlexView style={styles.footer} alignItems="center" justifyContent="center">
155162
{next && !loading && (
156163
<Link size="md" style={styles.loadMoreButton} onPress={handleLoadMore}>
157164
Load more
158165
</Link>
159166
)}
160-
{loading && !refreshing && <LoadingSpinner color="accent-100" />}
167+
{loading && <LoadingSpinner color="accent-100" />}
161168
</FlexView>
162169
)}
163170
</ScrollView>

packages/scaffold/src/partials/w3m-account-activity/styles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export default StyleSheet.create({
1818
height: 40
1919
},
2020
placeholder: {
21-
minHeight: 200
21+
minHeight: 200,
22+
flex: 0
2223
},
2324
loadMoreButton: {
2425
alignSelf: 'center',

0 commit comments

Comments
 (0)