Skip to content

Commit

Permalink
fix(app): rank, analytics (#1221)
Browse files Browse the repository at this point in the history
  • Loading branch information
happylolonly authored Jul 30, 2024
1 parent f3a90cc commit 71eb480
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 37 deletions.
6 changes: 4 additions & 2 deletions src/containers/ipfs/components/AdviserMeta/AdviserMeta.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Rank, Account } from 'src/components';
import { timeSince, formatCurrency } from 'src/utils/utils';
import useRank from 'src/features/cyberlinks/rank/useRank';
import { Link } from 'react-router-dom';
import { routes } from 'src/routes';
import useGetCreator from '../../hooks/useGetCreator';
import { PREFIXES } from '../metaInfo';
import styles from './AdviserMeta.module.scss';
import useRank from 'src/features/cyberlinks/rank/useRank';

type Props = {
cid: string;
Expand Down Expand Up @@ -42,7 +44,7 @@ function AdviserMeta({ cid, type, size }: Props) {
<span>
🟥 {size ? formatCurrency(size, 'B', 0, PREFIXES) : 'unknown'}
</span>
<button disabled>🌓</button>
<Link to={routes.robot.routes.soul.path}>🌓</Link>
</div>
</div>
);
Expand Down
2 changes: 0 additions & 2 deletions src/containers/ipfs/hooks/useGetDiscussion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ function useGetLinks(
where.neuron = { _eq: neuron };
}

console.log('search neuron:', neuron);

// always no next page when skip
const [hasNextPage, setHasNextPage] = useState(!skip);
const [isInitialLoading, setIsInitialLoading] = useState(true);
Expand Down
23 changes: 4 additions & 19 deletions src/features/cyberlinks/rank/useRank.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
import { useEffect, useState } from 'react';
import { useQueryClient } from 'src/contexts/queryClient';
import useQueryClientMethod from 'src/hooks/useQueryClientMethod';

function useRank(cid: string) {
const [rank, setRank] = useState<number>();
const { data } = useQueryClientMethod('rank', [cid]);

const queryClient = useQueryClient();
const rank = data?.rank;

useEffect(() => {
(async () => {
if (!queryClient) {
return;
}

return;

const response = await queryClient.rank(cid);

setRank(Number(response.rank));
})();
}, [cid, queryClient]);

return rank;
return rank ? Number(rank) : undefined;
}

export default useRank;
2 changes: 1 addition & 1 deletion src/hooks/useQueryClientMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function useQueryClientMethod<T extends keyof CyberClient>(
>(
['queryClientMethod', methodName, memoParams],
() => {
const func = queryClient![methodName];
const func = queryClient![methodName].bind(queryClient);

// refactor
if (memoParams) {
Expand Down
18 changes: 5 additions & 13 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,13 @@
<div id="progress-data"></div>
</div>
</div>

<script
defer
data-domain="ready.cyb.ai"
src="https://metrics.cyb.ai/js/script.js"
></script>
</body>

<script>
window.cyb = {};
const script = document.createElement('script');
script.src = 'https://metrics.cyb.ai/js/script.js';
script.setAttribute('data-domain', location.host);
script.defer = true;
document.body.appendChild(script);
</script>

<script
defer
data-domain="cyb.ai"
src="https://metrics.cyb.ai/js/script.js"
></script>
</html>
3 changes: 3 additions & 0 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export const routes = {
brain: {
path: '/robot/brain',
},
soul: {
path: '/robot/soul',
},
},
},
robotPassport: {
Expand Down

0 comments on commit 71eb480

Please sign in to comment.