Skip to content

Commit fa4120f

Browse files
fix
1 parent 55df113 commit fa4120f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

ui/home/useInferenceType.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,23 @@ export default function useInferenceType(tx: Transaction | undefined, isLoading:
4141
const logsData: LogsResponseTx | undefined = data;
4242

4343
return useMemo(() => {
44+
// Not an inference transaction
4445
if (!isInferenceTx) {
4546
return null;
4647
}
4748

48-
// Don't show spinner if transaction failed
49+
// Transaction failed - don't show inference
4950
if (isTxFailed) {
5051
return null;
5152
}
5253

53-
// Don't show spinner if query is not enabled (e.g., no status yet)
54+
// Query not enabled yet (e.g., no status/hash yet)
5455
if (!isQueryEnabled) {
5556
return null;
5657
}
5758

58-
// Only show spinner if query is actively loading and we haven't fetched yet
59-
if (isQueryLoading && !isFetched && !logsData?.items) {
59+
// Show loading if: we have placeholder data OR (query is loading AND no data yet)
60+
if (isPlaceholderData || (isQueryLoading && !logsData?.items?.length)) {
6061
return {
6162
type: null,
6263
modelCID: null,
@@ -65,12 +66,13 @@ export default function useInferenceType(tx: Transaction | undefined, isLoading:
6566
};
6667
}
6768

68-
// If query has completed but no data, return null (no inference)
69-
if (isFetched && !logsData?.items) {
69+
// Query completed but no logs
70+
if (isFetched && !logsData?.items?.length) {
7071
return null;
7172
}
7273

73-
if (!logsData?.items) {
74+
// No logs data yet
75+
if (!logsData?.items?.length) {
7476
return null;
7577
}
7678

@@ -90,6 +92,7 @@ export default function useInferenceType(tx: Transaction | undefined, isLoading:
9092
return item;
9193
}).filter((i) => i.address.hash === SUPPORTED_INFERENCE_ADDRESSES.InferenceHub);
9294

95+
// No inference logs found
9396
if (!inferenceHubLogs.length) {
9497
return null;
9598
}
@@ -118,7 +121,7 @@ export default function useInferenceType(tx: Transaction | undefined, isLoading:
118121
type,
119122
modelCID,
120123
mode,
121-
isLoading: isPlaceholderData,
124+
isLoading: false, // We have real data, not loading
122125
};
123126
}, [ isInferenceTx, logsData, isPlaceholderData, isQueryLoading, isFetched, isTxFailed, isQueryEnabled ]);
124127
}

0 commit comments

Comments
 (0)