Skip to content

Commit

Permalink
Callback fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hide-on-bush-x committed Mar 2, 2023
1 parent e956fda commit ddd1e68
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/components/masa-interface/masa-interface.tsx
Expand Up @@ -65,8 +65,7 @@ export const MasaInterface = ({
if (!identity?.identityId && scope?.includes('identity'))
return 'createIdentity';
if (
((!identity?.identityId && !soulnames) ||
(!identity?.identityId && soulnames && soulnames.length === 0)) &&
(!soulnames || (soulnames && soulnames.length === 0)) &&
scope?.includes('soulname')
)
return 'createSoulname';
Expand Down
7 changes: 2 additions & 5 deletions src/provider/modules/modal/modal.ts
Expand Up @@ -24,16 +24,13 @@ export const useModal = (
const closeModal = useCallback(
(forceCallback?: boolean) => {
setModalOpen(false);

if (
!forcedPage &&
areScopesFullfiled &&
!!modalCallback &&
isLoggedIn &&
isConnected &&
(masa?.config.network
? network?.name.includes(masa.config.network)
: true)
isConnected
) {
modalCallback();
} else if (forceCallback && modalCallback) {
Expand Down
3 changes: 3 additions & 0 deletions src/provider/modules/network/network.ts
Expand Up @@ -35,6 +35,9 @@ export const useNetwork = (
if (!provider) return;

const newNetwork = await provider.provider?.getNetwork();

console.log({newNetwork})

setNetwork(newNetwork ?? undefined);
}, [provider]);

Expand Down
3 changes: 2 additions & 1 deletion src/provider/modules/scopes/scopes.ts
Expand Up @@ -7,13 +7,14 @@ export const useScopes = (
) => {
const [scope, setScope] = useState<string[]>([]);
const areScopesFullfiled = useMemo(() => {
console.log({ scope, soulnames, isLoggedIn });
if (scope?.includes('soulname') && (soulnames?.length ?? 0) === 0)
return false;

if (scope?.includes('auth') && !isLoggedIn) return false;

return true;
}, [soulnames, scope]);
}, [soulnames, scope, isLoggedIn]);

return { scope, setScope, areScopesFullfiled };
};

0 comments on commit ddd1e68

Please sign in to comment.