Skip to content

Commit

Permalink
fix: correct swr error merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeday committed Aug 19, 2024
1 parent 63cb002 commit 3805e0e
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions features/ipfs/security-status-banner/use-remote-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const useRemoteVersion = () => {

// we use directly non-optimistic manifest data
// can't trust static props(in IPFS esp) to generate warnings/disconnect wallet
const { data, error } = useConfig().externalConfig.fetchMeta;
const externalConfigSwr = useConfig().externalConfig.fetchMeta;
const { data, error } = externalConfigSwr;

// ens&cid extraction
return useLidoSWR<EnsHashCheckReturn>(
['swr:use-remote-version', data],
const swr = useLidoSWR<EnsHashCheckReturn>(
['swr:use-remote-version', externalConfigSwr.data],
async (): Promise<EnsHashCheckReturn> => {
if (data?.ens) {
const resolver = await provider.getResolver(data.ens);
Expand Down Expand Up @@ -52,4 +52,22 @@ export const useRemoteVersion = () => {
isPaused: () => !(data || error),
},
);

// merged externalConfigSwr && cidSwr
return {
data: swr.data,
get initialLoading() {
return (
swr.initialLoading ||
(externalConfigSwr.data == null && externalConfigSwr.isValidating)
);
},
get loading() {
return swr.loading || externalConfigSwr.isValidating;
},
get error() {
return swr.error || error;
},
update: swr.update,
};
};

0 comments on commit 3805e0e

Please sign in to comment.