mirror of
https://github.com/Qortal/q-fund-v2.git
synced 2025-01-30 14:52:19 +00:00
Merge pull request #3 from QuickMythril/remove-invalid
Filter invalid results from crowdfund list
This commit is contained in:
commit
5927bf8679
@ -2,6 +2,7 @@ import React from "react";
|
|||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import {
|
import {
|
||||||
addToHashMap,
|
addToHashMap,
|
||||||
|
removeFromHashMap,
|
||||||
upsertCrowdfunds,
|
upsertCrowdfunds,
|
||||||
Crowdfund,
|
Crowdfund,
|
||||||
} from "../state/features/crowdfundSlice";
|
} from "../state/features/crowdfundSlice";
|
||||||
@ -48,8 +49,11 @@ export const useFetchCrowdfunds = () => {
|
|||||||
identifier,
|
identifier,
|
||||||
content,
|
content,
|
||||||
});
|
});
|
||||||
|
if (res?.isValid) {
|
||||||
dispatch(addToHashMap(res));
|
dispatch(addToHashMap(res));
|
||||||
|
} else {
|
||||||
|
dispatch(removeFromHashMap(identifier));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCrowdfunds = React.useCallback(async () => {
|
const getCrowdfunds = React.useCallback(async () => {
|
||||||
|
@ -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 { useNavigate } from "react-router-dom";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { RootState } from "../../state/store";
|
import { RootState } from "../../state/store";
|
||||||
@ -84,13 +84,17 @@ export const CrowdfundList = () => {
|
|||||||
}
|
}
|
||||||
}, [getCrowdfundHandlerMount, globalCrowdfunds]);
|
}, [getCrowdfundHandlerMount, globalCrowdfunds]);
|
||||||
|
|
||||||
|
const filteredCrowdfunds = useMemo(() => {
|
||||||
|
return crowdfunds.filter((crowdfund: Crowdfund) => hashMapCrowdfunds[crowdfund.id]?.isValid);
|
||||||
|
}, [crowdfunds, hashMapCrowdfunds]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CrowdfundListWrapper>
|
<CrowdfundListWrapper>
|
||||||
<CrowdfundListHeader>
|
<CrowdfundListHeader>
|
||||||
<CrowdfundListTitle>Most Recent Q-Funds</CrowdfundListTitle>
|
<CrowdfundListTitle>Most Recent Q-Funds</CrowdfundListTitle>
|
||||||
</CrowdfundListHeader>
|
</CrowdfundListHeader>
|
||||||
<CrowdfundContainer container spacing={3} direction={"row"}>
|
<CrowdfundContainer container spacing={3} direction={"row"}>
|
||||||
{crowdfunds.map((crowdfund: Crowdfund) => {
|
{filteredCrowdfunds.map((crowdfund: Crowdfund) => {
|
||||||
const existingCrowdfund = hashMapCrowdfunds[crowdfund.id];
|
const existingCrowdfund = hashMapCrowdfunds[crowdfund.id];
|
||||||
let hasHash = false;
|
let hasHash = false;
|
||||||
let crowdfundObj = crowdfund;
|
let crowdfundObj = crowdfund;
|
||||||
|
Loading…
Reference in New Issue
Block a user