Skip to content

Commit 944e16f

Browse files
authored
fix(all): [LW-8912] fix missing pending txs in activity & stuck infinite scroll on bigger resolutions (#696)
* fix(all): fix pending txs not appearing at the top of activities * fix(all): fix activities list not loading new pages on bigger screens * refactor(all): update naming/comment in the hotfixed infinite scroll
1 parent e8896c0 commit 944e16f

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

apps/browser-extension-wallet/src/stores/slices/wallet-activities-slice.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ const getWalletActivitiesObservable = async ({
308308
map(async (allTransactions) =>
309309
(await allTransactions).sort((firstTx, secondTx) => {
310310
// ensure pending txs are always first
311-
if (firstTx.status === ActivityStatus.PENDING && secondTx.status !== ActivityStatus.PENDING) return 1;
312-
if (secondTx.status === ActivityStatus.PENDING && firstTx.status !== ActivityStatus.PENDING) return -1;
311+
if (firstTx.status === ActivityStatus.PENDING && secondTx.status !== ActivityStatus.PENDING) return -1;
312+
if (secondTx.status === ActivityStatus.PENDING && firstTx.status !== ActivityStatus.PENDING) return 1;
313313
// otherwise sort by date
314314
return secondTx.date.getTime() - firstTx.date.getTime();
315315
})

packages/core/src/ui/components/Activity/GroupedAssetActivityList.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,30 @@ export const GroupedAssetActivityList = ({
2626
withTitle,
2727
isDrawerView
2828
}: GroupedAssetActivityListProps): React.ReactElement => {
29-
const TAKE = 5;
29+
// workaround for bug in react-infinite-scroll-component
30+
// related to not loading more elements if the height of the container is less than the height of the window
31+
// see: https://github.com/ankeetmaini/react-infinite-scroll-component/issues/380
32+
// ticket for proper fix on our end: https://input-output.atlassian.net/browse/LW-8986
33+
// initialWindowHeight state needed to ensure that page size remains the same if window is resized
34+
const [initialWindowHeight] = useState(window.innerHeight);
35+
const ESTIMATED_MIN_GROUP_HEIGHT = 100;
36+
// eslint-disable-next-line no-magic-numbers
37+
const pageSize = Math.max(5, Math.floor(initialWindowHeight / ESTIMATED_MIN_GROUP_HEIGHT));
38+
3039
const FAKE_LOAD_TIMEOUT = 1000;
3140
const [skip, setSkip] = useState(0);
32-
const [paginatedLists, setPaginatedLists] = useState(take(lists, skip + TAKE));
41+
const [paginatedLists, setPaginatedLists] = useState(take(lists, skip + pageSize));
3342

3443
const loadMoreData = () => {
3544
setTimeout(() => {
36-
setSkip(skip + TAKE);
45+
setSkip(skip + pageSize);
3746
}, FAKE_LOAD_TIMEOUT);
3847
};
3948

4049
useEffect(() => {
4150
if (lists.length === 0) return;
42-
setPaginatedLists(take(lists, skip + TAKE));
43-
}, [skip, lists]);
51+
setPaginatedLists(take(lists, skip + pageSize));
52+
}, [skip, lists, pageSize]);
4453

4554
return (
4655
<InfiniteScroll

0 commit comments

Comments
 (0)