diff --git a/src/renderer/src/views/ManageAccountView.vue b/src/renderer/src/views/ManageAccountView.vue deleted file mode 100644 index 9df7a09d..00000000 --- a/src/renderer/src/views/ManageAccountView.vue +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/renderer/src/views/TabsView.vue b/src/renderer/src/views/TabsView.vue index 1220db30..b5421fbc 100644 --- a/src/renderer/src/views/TabsView.vue +++ b/src/renderer/src/views/TabsView.vue @@ -5,8 +5,8 @@ import AccountView from './AccountView.vue'; import CydAPIClient from '../../../cyd-api-client'; import type { DeviceInfo } from '../types'; import type { Account } from '../../../shared_types'; -import ManageAccountView from './ManageAccountView.vue'; import AboutView from './AboutView.vue'; +import { openURL } from '../util'; // Get the global emitter const vueInstance = getCurrentInstance(); @@ -24,12 +24,10 @@ const refreshDeviceInfo = inject('refreshDeviceInfo') as () => Promise; const refreshAPIClient = inject('refreshAPIClient') as () => Promise; const hideAllAccounts = ref(false); -const showManageAccount = ref(false); const showAbout = ref(false); const accountClicked = async (account: Account) => { - hideManageAccountView(); hideAboutView(); activeAccountID.value = account.id; @@ -48,7 +46,6 @@ const accountClicked = async (account: Account) => { }; const addAccountClicked = async () => { - hideManageAccountView(); hideAboutView(); // Do we already have an unknown account? @@ -91,7 +88,6 @@ const removeAccount = async (accountID: number) => { } const accountSelected = async (account: Account, accountType: string) => { - hideManageAccountView(); hideAboutView(); try { @@ -131,44 +127,27 @@ const outsideUserMenuClicked = (event: MouseEvent) => { } }; -const showManageAccountView = () => { +const openDashboard = async () => { userBtnShowMenu.value = false; - showManageAccount.value = true; - showAbout.value = false; - hideAllAccounts.value = true; -}; - -const hideManageAccountView = () => { - showManageAccount.value = false; - showAbout.value = false; - hideAllAccounts.value = false; + const dashURL = await window.electron.getDashURL(); + const nativeLoginURL = `${dashURL}/#/native-login/${deviceInfo.value?.userEmail}/${deviceInfo.value?.deviceToken}/manage`; + openURL(nativeLoginURL); }; -emitter?.on('show-manage-account', showManageAccountView); +emitter?.on('show-manage-account', openDashboard); const manageAccountClicked = async () => { - localStorage.setItem('manageAccountMode', 'manage'); - showManageAccountView(); -}; - -const redirectToAccount = (accountID: number) => { - // This forces the account to re-check if the user is signed in and if premium is enabled - emitter?.emit('signed-in'); - - activeAccountID.value = accountID; - hideManageAccountView(); + openDashboard(); }; const showAboutView = () => { userBtnShowMenu.value = false; - showManageAccount.value = false; showAbout.value = true; hideAllAccounts.value = true; }; const hideAboutView = () => { - showManageAccount.value = false; showAbout.value = false; hideAllAccounts.value = false; }; @@ -178,7 +157,6 @@ const aboutClicked = async () => { }; const signInClicked = async () => { - localStorage.setItem('manageAccountMode', 'manage'); emitter?.emit('show-sign-in'); }; @@ -207,12 +185,9 @@ const signOutClicked = async () => { await refreshDeviceInfo(); await refreshAPIClient(); - showManageAccount.value = false; userBtnShowMenu.value = false; emitter?.emit('signed-out'); - - hideManageAccountView(); }; const checkForUpdatesClicked = async () => { @@ -242,7 +217,7 @@ onMounted(async () => { document.addEventListener('click', outsideUserMenuClicked); document.addEventListener('auxclick', outsideUserMenuClicked); - emitter?.on('signed-in', showManageAccountView); + emitter?.on('signed-in', openDashboard); emitter?.on('account-updated', reloadAccounts); }); @@ -339,9 +314,6 @@ onUnmounted(async () => { :class="{ 'hide': hideAllAccounts || activeAccountID !== account.id }" @account-selected="accountSelected" @on-remove-clicked="removeAccount(account.id)" /> - - - diff --git a/src/renderer/src/views/x/AccountXView.vue b/src/renderer/src/views/x/AccountXView.vue index d36ca842..fa77d80f 100644 --- a/src/renderer/src/views/x/AccountXView.vue +++ b/src/renderer/src/views/x/AccountXView.vue @@ -219,15 +219,17 @@ const updateUserPremium = async () => { return; } userPremium.value = userPremiumResp.premium_access; + + if (!userPremium.value) { + console.log('User does not have Premium access'); + emitter?.emit(`x-premium-check-failed-${props.account.id}`); + } }; emitter?.on('signed-in', async () => { console.log('AccountXView: User signed in'); await updateUserAuthenticated(); await updateUserPremium(); - if (!userPremium.value) { - emitter?.emit('show-manage-account'); - } }); emitter?.on('signed-out', async () => { @@ -480,7 +482,7 @@ onUnmounted(async () => { + @start-jobs-just-save="startJobsJustSave" @update-user-premium="updateUserPremium" /> -import { getCurrentInstance } from 'vue'; +import { ref, getCurrentInstance } from 'vue'; import { AccountXViewModel, State @@ -19,22 +19,32 @@ const props = defineProps<{ // Emits const emit = defineEmits<{ setState: [value: State] - startJobsJustSave: [] + startJobsJustSave: [], + updateUserPremium: [], }>() // Buttons const signInClicked = async () => { - localStorage.setItem('manageAccountMode', 'premium'); - localStorage.setItem('manageAccountRedirectAccountID', props.model.account?.id.toString()); emitter?.emit("show-sign-in"); }; const manageAccountClicked = async () => { - localStorage.setItem('manageAccountMode', 'premium'); - localStorage.setItem('manageAccountRedirectAccountID', props.model.account?.id.toString()); emitter?.emit("show-manage-account"); }; +const iveUpgradedClicked = async () => { + emit('updateUserPremium'); +}; + +const showNoPremiumError = ref(false); + +emitter?.on(`x-premium-check-failed-${props.model.account.id}`, async () => { + showNoPremiumError.value = true; + setTimeout(() => { + showNoPremiumError.value = false; + }, 5000); +}); + const backClicked = async () => { emit('setState', State.WizardReview); }; @@ -52,31 +62,31 @@ const backClicked = async () => { - Deleting tweets older than a set number of days + Delete tweets older than a set number of days - Deleting tweets unless they have at least a certain number of retweets + Delete tweets unless they have at least a certain number of retweets - Deleting tweets unless they have at least a certain number of likes + Delete tweets unless they have at least a certain number of likes - Deleting retweets older than a set number of days + Delete retweets older than a set number of days - Unfollowing everyone + Unfollow everyone - Deleting likes + Delete likes - Deleting bookmarks + Delete bookmarks - Deleting direct messages + Delete direct messages @@ -98,11 +108,21 @@ const backClicked = async () => { Sign In - - - Manage My Account - + + + + Manage My Account + + + + + I've Upgraded + + + + You haven't upgraded to Premium yet. Please try again. + +