Browse Source

Merge pull request #17 from QuickMythril/superlike-fix

Improve Superlike validation
pull/20/head
Qortal Dev 7 months ago committed by GitHub
parent
commit
b408a99d8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 77
      src/wrappers/GlobalWrapper.tsx

77
src/wrappers/GlobalWrapper.tsx

@ -143,46 +143,53 @@ const GlobalWrapper: React.FC<Props> = ({ children, setTheme }) => {
const getSuperlikes = useCallback(async () => { const getSuperlikes = useCallback(async () => {
try { try {
const url = `/arbitrary/resources/search?mode=ALL&service=BLOG_COMMENT&query=${SUPER_LIKE_BASE}&limit=20&includemetadata=true&reverse=true&excludeblocked=true`; let totalCount = 0
const response = await fetch(url, { let validCount = 0
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
const responseData = await response.json();
let comments: any[] = []; let comments: any[] = [];
for (const comment of responseData) { while (validCount < 20 && totalCount < 100) {
if ( const url = `/arbitrary/resources/search?mode=ALL&service=BLOG_COMMENT&query=${SUPER_LIKE_BASE}&limit=1&offset=${totalCount}&includemetadata=true&reverse=true&excludeblocked=true`;
comment.identifier && const response = await fetch(url, {
comment.name && method: "GET",
comment?.metadata?.description headers: {
) { "Content-Type": "application/json",
try { },
const result = extractSigValue(comment?.metadata?.description); });
if (!result) continue; const responseData = await response.json();
const res = await getPaymentInfo(result); if (responseData && responseData.length > 0) {
for (const comment of responseData) {
if ( if (
+res?.amount >= minPriceSuperlike && comment.identifier &&
isTimestampWithinRange(res?.timestamp, comment.created) comment.name &&
comment?.metadata?.description
) { ) {
addSuperlikeRawDataGetToList({ try {
name: comment.name, const result = extractSigValue(comment?.metadata?.description);
identifier: comment.identifier, if (!result) continue;
content: comment, const res = await getPaymentInfo(result);
}); if (
+res?.amount >= minPriceSuperlike &&
comments = [ isTimestampWithinRange(res?.timestamp, comment.created)
...comments, ) {
{ addSuperlikeRawDataGetToList({
...comment, name: comment.name,
message: "", identifier: comment.identifier,
amount: res.amount, content: comment,
}, });
]; comments = [
...comments,
{
...comment,
message: "",
amount: res.amount,
},
];
validCount++;
}
} catch (error) {}
} }
} catch (error) {} }
} }
totalCount++;
} }
dispatch(setSuperlikesAll(comments)); dispatch(setSuperlikesAll(comments));
} catch (error) { } catch (error) {

Loading…
Cancel
Save