Skip to content

fix(all): [LW-8912] fix missing pending txs in activity & stuck infinite scroll on bigger resolutions #696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ const getWalletActivitiesObservable = async ({
map(async (allTransactions) =>
(await allTransactions).sort((firstTx, secondTx) => {
// ensure pending txs are always first
if (firstTx.status === ActivityStatus.PENDING && secondTx.status !== ActivityStatus.PENDING) return 1;
if (secondTx.status === ActivityStatus.PENDING && firstTx.status !== ActivityStatus.PENDING) return -1;
if (firstTx.status === ActivityStatus.PENDING && secondTx.status !== ActivityStatus.PENDING) return -1;
if (secondTx.status === ActivityStatus.PENDING && firstTx.status !== ActivityStatus.PENDING) return 1;
// otherwise sort by date
return secondTx.date.getTime() - firstTx.date.getTime();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,30 @@ export const GroupedAssetActivityList = ({
withTitle,
isDrawerView
}: GroupedAssetActivityListProps): React.ReactElement => {
const TAKE = 5;
// workaround for bug in react-infinite-scroll-component
// related to not loading more elements if the height of the container is less than the height of the window
// see: https://github.com/ankeetmaini/react-infinite-scroll-component/issues/380
// ticket for proper fix on our end: https://input-output.atlassian.net/browse/LW-8986
// initialWindowHeight state needed to ensure that page size remains the same if window is resized
const [initialWindowHeight] = useState(window.innerHeight);
const ESTIMATED_MIN_GROUP_HEIGHT = 100;
// eslint-disable-next-line no-magic-numbers
const pageSize = Math.max(5, Math.floor(initialWindowHeight / ESTIMATED_MIN_GROUP_HEIGHT));

const FAKE_LOAD_TIMEOUT = 1000;
const [skip, setSkip] = useState(0);
const [paginatedLists, setPaginatedLists] = useState(take(lists, skip + TAKE));
const [paginatedLists, setPaginatedLists] = useState(take(lists, skip + pageSize));

const loadMoreData = () => {
setTimeout(() => {
setSkip(skip + TAKE);
setSkip(skip + pageSize);
}, FAKE_LOAD_TIMEOUT);
};

useEffect(() => {
if (lists.length === 0) return;
setPaginatedLists(take(lists, skip + TAKE));
}, [skip, lists]);
setPaginatedLists(take(lists, skip + pageSize));
}, [skip, lists, pageSize]);

return (
<InfiniteScroll
Expand Down