Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zlayine committed Jul 12, 2024
1 parent 616cc7a commit d79d688
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion resources/js/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ const initialTheme = () => {
})();
onMounted(() => {
useConnectionStore().loadWallet();
setTimeout(() => {
useConnectionStore().loadWallet();
}, 500);
});
watch(
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/SideNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
>{{ pageTitle() }}</span
>
</div>
<div class="mt-5 flex flex-grow flex-col">
<div class="mt-4 flex flex-grow flex-col">
<nav class="flex-1" aria-label="Sidebar">
<RouterLink
v-for="item in navigations"
Expand Down
16 changes: 10 additions & 6 deletions resources/js/store/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ export const useConnectionStore = defineStore('connection', {
},
async loadWallet() {
if (this.provider) {
await this.connectWallet(this.provider, () => {});
await this.connectWallet(this.provider, () => {}, false);
if (!this.wallet) {
return;
}
await this.getAccounts();
AuthApi.setUserAccounts(this.accounts.map((account) => publicKeyToAddress(account.address)));
}
},
async connectWallet(provider: string, endLoading: Function) {
async connectWallet(provider: string, endLoading: Function, notify = true) {
if (provider === 'wc') {
await this.connectWC(endLoading);
}

if (provider === 'polkadot.js') {
await this.connectPolkadotJS();
await this.connectPolkadotJS(notify);
}
},
async initWalletClient() {
Expand Down Expand Up @@ -120,16 +120,20 @@ export const useConnectionStore = defineStore('connection', {
this.account = null;
}
},
async connectPolkadotJS() {
async connectPolkadotJS(notify: boolean) {
const pkjs = new PolkadotjsWallet();
if (pkjs.installed) {
await pkjs.enable('Platform');
this.wallet = true;
this.provider = 'polkadot.js';
this.walletSession = pkjs;
snackbar.success({ title: 'Polkadot.js extension connected', save: false });
if (notify) {
snackbar.success({ title: 'Polkadot.js extension connected', save: false });
}
} else {
snackbar.error({ title: 'Polkadot.js extension is not installed' });
if (notify) {
snackbar.error({ title: 'Polkadot.js extension is not installed' });
}
}
},

Expand Down

0 comments on commit d79d688

Please sign in to comment.