Skip to content

Commit

Permalink
feat: listen for extension connect (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
euharrison authored Dec 3, 2024
1 parent 5041ef1 commit 632aee0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions apps/namadillo/src/App/Setup/ExtensionLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,24 @@ export const ExtensionLoader = ({
);

const chainId = chain?.chainId;
const keychainPromise = namadaKeychain.get();

useEffect(() => {
keychainPromise.then((injectedNamada) => {
if (injectedNamada) {
return setAttachStatus("attached");
}
setAttachStatus("detached");
});
const getNamada = (): void => {
namadaKeychain.get().then((injectedNamada) => {
if (injectedNamada) {
setAttachStatus("attached");
return;
}
setAttachStatus("detached");
setTimeout(() => getNamada());
});
};
getNamada();
}, []);

useEffect(() => {
if (chainId && attachStatus === "attached") {
keychainPromise.then((injectedNamada) => {
namadaKeychain.get().then((injectedNamada) => {
injectedNamada.isConnected(chainId).then((isConnected) => {
if (isConnected) {
return setConnectionStatus("connected");
Expand Down

1 comment on commit 632aee0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.