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. 13
      src/wrappers/GlobalWrapper.tsx

13
src/wrappers/GlobalWrapper.tsx

@ -143,7 +143,11 @@ const GlobalWrapper: React.FC<Props> = ({ children, setTheme }) => {
const getSuperlikes = useCallback(async () => {
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
let validCount = 0
let comments: any[] = [];
while (validCount < 20 && totalCount < 100) {
const url = `/arbitrary/resources/search?mode=ALL&service=BLOG_COMMENT&query=${SUPER_LIKE_BASE}&limit=1&offset=${totalCount}&includemetadata=true&reverse=true&excludeblocked=true`;
const response = await fetch(url, {
method: "GET",
headers: {
@ -151,7 +155,7 @@ const GlobalWrapper: React.FC<Props> = ({ children, setTheme }) => {
},
});
const responseData = await response.json();
let comments: any[] = [];
if (responseData && responseData.length > 0) {
for (const comment of responseData) {
if (
comment.identifier &&
@ -171,7 +175,6 @@ const GlobalWrapper: React.FC<Props> = ({ children, setTheme }) => {
identifier: comment.identifier,
content: comment,
});
comments = [
...comments,
{
@ -180,10 +183,14 @@ const GlobalWrapper: React.FC<Props> = ({ children, setTheme }) => {
amount: res.amount,
},
];
validCount++;
}
} catch (error) {}
}
}
}
totalCount++;
}
dispatch(setSuperlikesAll(comments));
} catch (error) {
console.error(error);

Loading…
Cancel
Save