diff --git a/src/components/MenuAccount.vue b/src/components/MenuAccount.vue index 63ff1dbf16c..d62cd253838 100644 --- a/src/components/MenuAccount.vue +++ b/src/components/MenuAccount.vue @@ -6,17 +6,8 @@ const props = defineProps<{ const emit = defineEmits(['switchWallet']); const { domain } = useApp(); const { logout } = useWeb3(); +const { modalEmailOpen } = useModal(); const router = useRouter(); -const { userState, loadEmailSubscriptions } = useEmailSubscription(); - -const showModalEmail = ref(false); - -onMounted(loadEmailSubscriptions); -watch(showModalEmail, () => { - if (!showModalEmail.value) { - loadEmailSubscriptions(); - } -}); function handleAction(e) { if (e === 'viewProfile') @@ -29,7 +20,7 @@ function handleAction(e) { }); if (e === 'switchWallet') return emit('switchWallet'); if (e === 'subscribeEmail') { - showModalEmail.value = true; + modalEmailOpen.value = true; return true; } @@ -90,20 +81,6 @@ function handleAction(e) { - - - + diff --git a/src/components/ModalEmail.vue b/src/components/ModalEmail.vue new file mode 100644 index 00000000000..05d556d8261 --- /dev/null +++ b/src/components/ModalEmail.vue @@ -0,0 +1,51 @@ + + + diff --git a/src/components/ModalEmailManagement.vue b/src/components/ModalEmailManagement.vue index 0a008ab5896..a7a4b831669 100644 --- a/src/components/ModalEmailManagement.vue +++ b/src/components/ModalEmailManagement.vue @@ -1,8 +1,4 @@ diff --git a/src/components/ModalEmailResend.vue b/src/components/ModalEmailResend.vue index 0c9369bd64c..b9f3dd4df62 100644 --- a/src/components/ModalEmailResend.vue +++ b/src/components/ModalEmailResend.vue @@ -1,23 +1,13 @@ diff --git a/src/components/ModalEmailSubscription.vue b/src/components/ModalEmailSubscription.vue index eb4493b11c3..7be76dc906b 100644 --- a/src/components/ModalEmailSubscription.vue +++ b/src/components/ModalEmailSubscription.vue @@ -1,8 +1,4 @@ diff --git a/src/components/ModalPostVote.vue b/src/components/ModalPostVote.vue index 136d167e7c3..64f2e06a055 100644 --- a/src/components/ModalPostVote.vue +++ b/src/components/ModalPostVote.vue @@ -4,7 +4,8 @@ import { ExtendedSpace, Proposal } from '@/helpers/interfaces'; const { shareVote, shareProposalTwitter, shareProposalHey } = useSharing(); const { web3Account } = useWeb3(); -const { userState } = useEmailSubscription(); +const { userState, loadEmailSubscriptions, initialized } = + useEmailSubscription(); const props = defineProps<{ open: boolean; @@ -34,6 +35,12 @@ function share(shareTo: 'twitter' | 'hey') { choices: getChoiceString(props.proposal, props.selectedChoices) }); } + +onMounted(() => { + if (!initialized.value) { + loadEmailSubscriptions(); + } +}); diff --git a/src/composables/useEmailSubscription.ts b/src/composables/useEmailSubscription.ts index 171a1a3c663..087f2a9eab0 100644 --- a/src/composables/useEmailSubscription.ts +++ b/src/composables/useEmailSubscription.ts @@ -14,6 +14,7 @@ function useEmailSubscriptionComposable() { const userState = ref('NOT_SUBSCRIBED'); const error = ref(''); + const initialized = ref(false); const loading = ref(false); const apiSubscriptions = ref([]); @@ -50,6 +51,7 @@ function useEmailSubscriptionComposable() { userState.value = usrState; apiSubscriptions.value = subscriptions || []; loading.value = false; + initialized.value = true; }; const subscribe = async (email: string) => { @@ -88,7 +90,8 @@ function useEmailSubscriptionComposable() { subscribe, updateSubscriptions, loadEmailSubscriptions, - loading + loading, + initialized }; } diff --git a/src/composables/useModal.ts b/src/composables/useModal.ts index aa5686ea0b8..88edd058b65 100644 --- a/src/composables/useModal.ts +++ b/src/composables/useModal.ts @@ -1,6 +1,7 @@ const modalAccountOpen = ref(false); const isModalPostVoteOpen = ref(false); +const modalEmailOpen = ref(false); export function useModal() { - return { modalAccountOpen, isModalPostVoteOpen }; + return { modalAccountOpen, isModalPostVoteOpen, modalEmailOpen }; }