mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* Metadata: send address to fetchers once visited Fixes #2723 * fix ts
41 lines
1003 B
TypeScript
41 lines
1003 B
TypeScript
import React from 'react';
|
|
|
|
import type { AddressCounters } from 'types/api/address';
|
|
|
|
import config from 'configs/app';
|
|
import useApiFetch from 'lib/api/useApiFetch';
|
|
|
|
const feature = config.features.addressMetadata;
|
|
|
|
interface Params {
|
|
address: string | undefined;
|
|
counters: AddressCounters | undefined;
|
|
isEnabled: boolean;
|
|
}
|
|
|
|
const TXS_THRESHOLD = 500;
|
|
|
|
export default function useAddressMetadataInitUpdate({ address, counters, isEnabled }: Params) {
|
|
|
|
const apiFetch = useApiFetch();
|
|
|
|
React.useEffect(() => {
|
|
if (
|
|
feature.isEnabled &&
|
|
feature.isAddressTagsUpdateEnabled &&
|
|
address &&
|
|
isEnabled &&
|
|
counters?.transactions_count && Number(counters.transactions_count) > TXS_THRESHOLD
|
|
) {
|
|
apiFetch('metadata:address_submit', {
|
|
fetchParams: {
|
|
method: 'POST',
|
|
body: {
|
|
addresses: [ address ],
|
|
},
|
|
},
|
|
});
|
|
}
|
|
}, [ address, apiFetch, counters?.transactions_count, isEnabled ]);
|
|
}
|