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

fix: force user to login only on account dependent page #1045

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions apps/ui/src/stores/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const useNotificationsStore = defineStore('notifications', () => {
} else if (!followedSpacesIds.length && refreshNotificationInterval) {
clearInterval(refreshNotificationInterval);
refreshNotificationInterval = 0;
notifications.value = [];
}
},
{ immediate: true }
Expand Down
8 changes: 2 additions & 6 deletions apps/ui/src/views/My/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PROPOSALS_LIMIT = 20;
useTitle('Home');

const metaStore = useMetaStore();
const { modalAccountWithoutDismissOpen } = useModal();
const router = useRouter();
const followedSpacesStore = useFollowedSpacesStore();
const { web3 } = useWeb3();
const { loadVotes } = useAccount();
Expand Down Expand Up @@ -113,15 +113,11 @@ watch(
[() => web3.value.account, () => web3.value.authLoading],
([account, authLoading]) => {
if (!account && !authLoading) {
modalAccountWithoutDismissOpen.value = true;
router.replace({ name: 'my-explore' });
}
},
{ immediate: true }
);

onUnmounted(() => {
modalAccountWithoutDismissOpen.value = false;
});
</script>

<template>
Expand Down
18 changes: 16 additions & 2 deletions apps/ui/src/views/My/Notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import { _rt } from '@/helpers/utils';

const notificationsStore = useNotificationsStore();
const { modalAccountWithoutDismissOpen } = useModal();
const { web3 } = useWeb3();
const { setTitle } = useTitle();

watchEffect(async () => {
Expand All @@ -11,13 +13,25 @@ watchEffect(async () => {
});

watch(
() => notificationsStore.unreadNotificationsCount,
() => {
[
() => web3.value.account,
() => web3.value.authLoading,
() => notificationsStore.unreadNotificationsCount
],
([account, authLoading]) => {
if (!account && !authLoading) {
modalAccountWithoutDismissOpen.value = true;
}

notificationsStore.refreshLastUnreadTs();
},
{ immediate: true }
);

onUnmounted(() => {
modalAccountWithoutDismissOpen.value = false;
});

onUnmounted(() => notificationsStore.markAllAsRead());
</script>

Expand Down
17 changes: 16 additions & 1 deletion apps/ui/src/views/Settings.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<script setup lang="ts">
const { web3Account } = useWeb3();
const { web3, web3Account } = useWeb3();
const { modalAccountWithoutDismissOpen } = useModal();

watch(
[() => web3.value.account, () => web3.value.authLoading],
([account, authLoading]) => {
if (!account && !authLoading) {
modalAccountWithoutDismissOpen.value = true;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe better to redirect to home/explore page?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My reasoning is as follow:

user who wants these page have a direct link (bookmarks, etc…), and want their content. If not logged in, they would want to login, else it would not make sense to access these pages.

/home is different, as there’s a link from the landing page, and anyone can go there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bonustrack wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

Let's merge this for now

Copy link
Member

Choose a reason for hiding this comment

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

Make sense, I'll merge this

}
},
{ immediate: true }
);

onUnmounted(() => {
modalAccountWithoutDismissOpen.value = false;
});
</script>

<template>
Expand Down