3
0
mirror of https://github.com/Qortal/q-fund-v2.git synced 2025-01-28 22:02:20 +00:00

Filter invalid results from crowdfund list

This commit is contained in:
QuickMythril 2024-04-17 03:36:56 -04:00
parent b1f0173746
commit e2c1b3b43e
2 changed files with 12 additions and 4 deletions

View File

@ -2,6 +2,7 @@ import React from "react";
import { useDispatch, useSelector } from "react-redux";
import {
addToHashMap,
removeFromHashMap,
upsertCrowdfunds,
Crowdfund,
} from "../state/features/crowdfundSlice";
@ -48,8 +49,11 @@ export const useFetchCrowdfunds = () => {
identifier,
content,
});
dispatch(addToHashMap(res));
if (res?.isValid) {
dispatch(addToHashMap(res));
} else {
dispatch(removeFromHashMap(identifier));
}
};
const getCrowdfunds = React.useCallback(async () => {

View File

@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from "react";
import React, { useEffect, useMemo, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
import { useSelector } from "react-redux";
import { RootState } from "../../state/store";
@ -84,13 +84,17 @@ export const CrowdfundList = () => {
}
}, [getCrowdfundHandlerMount, globalCrowdfunds]);
const filteredCrowdfunds = useMemo(() => {
return crowdfunds.filter((crowdfund: Crowdfund) => hashMapCrowdfunds[crowdfund.id]?.isValid);
}, [crowdfunds, hashMapCrowdfunds]);
return (
<CrowdfundListWrapper>
<CrowdfundListHeader>
<CrowdfundListTitle>Most Recent Q-Funds</CrowdfundListTitle>
</CrowdfundListHeader>
<CrowdfundContainer container spacing={3} direction={"row"}>
{crowdfunds.map((crowdfund: Crowdfund) => {
{filteredCrowdfunds.map((crowdfund: Crowdfund) => {
const existingCrowdfund = hashMapCrowdfunds[crowdfund.id];
let hasHash = false;
let crowdfundObj = crowdfund;