Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: redirect logged users to /home #640

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion apps/ui/src/views/Landing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,26 @@ const SOCIALS = [
icon: ICGithub
}
];

const router = useRouter();
const { web3, authInitiated } = useWeb3();

watch(
() => web3.value.account,
account => {
if (!account) return;

router.push({ name: 'my-home' });
},
{ immediate: true }
);
</script>

<template>
<div>
<div v-if="!authInitiated || web3.authLoading" class="p-4">
Copy link
Member

Choose a reason for hiding this comment

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

If metamask is locked

Untitled 4

Is it expected? feels bit weird

Copy link
Member

@ChaituVR ChaituVR Aug 18, 2024

Choose a reason for hiding this comment

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

why we want to show a loader here 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To not flash the landing page.

Else, it will show the landing page, while we're connecting the user async

Copy link
Member

@ChaituVR ChaituVR Aug 18, 2024

Choose a reason for hiding this comment

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

We should have some localstorage variable (add value when user connects and delete if the user logout)
if user have this value, we should always redirect to /home , else show /

Then we wait for user wallet connection on /home, if user fails to connect his wallet, we should delete localstorage variable and redirect back to /

(also we should not try to auto-connect if user doesn't have this localstorage value, this may solve #478)

Copy link
Member

Choose a reason for hiding this comment

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

I think the issue is that we can not differentiate if the user is ready to be logged or if Metamask / user wallet is locked, this cause an issue where Metamask or WalletConnect will be triggered for login on first page load. Wagmi may fix that, or it could be with a change on Lock.

Copy link
Member

@bonustrack bonustrack Aug 19, 2024

Choose a reason for hiding this comment

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

The ideal behavior would be similar than Uniswap (which is using Wagmi), where user dont get Metamask or their wallet triggered if it's locked, but still autoconnect if it's not locked

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ideal behavior depends on some changes on lock side, and will be on another PR

<UiLoading />
</div>
<div v-else>
<div class="py-8 mb-6 border-b hero">
<UiContainer class="!max-w-screen-md my-1">
<h1 class="mb-4 mono max-w-[580px]">
Expand Down
Loading