mirror of
https://github.com/Qortal/qapp-core.git
synced 2025-06-14 17:41:20 +00:00
fix refetchData
This commit is contained in:
parent
f8bb556cdd
commit
f3917ba5c5
@ -70,7 +70,6 @@ export const usePublish = (
|
|||||||
const fetchPublish = useCallback(
|
const fetchPublish = useCallback(
|
||||||
async (
|
async (
|
||||||
metadataProp: QortalGetMetadata,
|
metadataProp: QortalGetMetadata,
|
||||||
returnTypeProp: ReturnType = "JSON"
|
|
||||||
) => {
|
) => {
|
||||||
let resourceExists = null;
|
let resourceExists = null;
|
||||||
let resource = null;
|
let resource = null;
|
||||||
@ -179,10 +178,15 @@ export const usePublish = (
|
|||||||
if (hasFetched.current) return;
|
if (hasFetched.current) return;
|
||||||
if (metadata?.identifier && metadata?.name && metadata?.service) {
|
if (metadata?.identifier && metadata?.name && metadata?.service) {
|
||||||
hasFetched.current = true;
|
hasFetched.current = true;
|
||||||
fetchPublish(metadata, returnType);
|
fetchPublish(metadata);
|
||||||
}
|
}
|
||||||
}, [metadata, returnType]);
|
}, [metadata, returnType]);
|
||||||
|
|
||||||
|
const refetchData = useCallback(async ()=> {
|
||||||
|
if(!metadata) throw new Error('usePublish is missing metadata')
|
||||||
|
return await fetchPublish(metadata)
|
||||||
|
}, [metadata])
|
||||||
|
|
||||||
|
|
||||||
const deleteResource = useCallback(async (publish: QortalGetMetadata) => {
|
const deleteResource = useCallback(async (publish: QortalGetMetadata) => {
|
||||||
const res = await qortalRequest({
|
const res = await qortalRequest({
|
||||||
@ -268,7 +272,7 @@ export const usePublish = (
|
|||||||
error,
|
error,
|
||||||
resource: publish || null,
|
resource: publish || null,
|
||||||
hasResource,
|
hasResource,
|
||||||
refetch: fetchPublish,
|
refetch: refetchData,
|
||||||
fetchPublish,
|
fetchPublish,
|
||||||
updatePublish,
|
updatePublish,
|
||||||
deletePublish: deleteResource,
|
deletePublish: deleteResource,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user