Skip to content
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
127 changes: 0 additions & 127 deletions src/renderer/src/views/ManageAccountView.vue

This file was deleted.

44 changes: 8 additions & 36 deletions src/renderer/src/views/TabsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -24,12 +24,10 @@ const refreshDeviceInfo = inject('refreshDeviceInfo') as () => Promise<void>;
const refreshAPIClient = inject('refreshAPIClient') as () => Promise<void>;

const hideAllAccounts = ref(false);
const showManageAccount = ref(false);

const showAbout = ref(false);

const accountClicked = async (account: Account) => {
hideManageAccountView();
hideAboutView();

activeAccountID.value = account.id;
Expand All @@ -48,7 +46,6 @@ const accountClicked = async (account: Account) => {
};

const addAccountClicked = async () => {
hideManageAccountView();
hideAboutView();

// Do we already have an unknown account?
Expand Down Expand Up @@ -91,7 +88,6 @@ const removeAccount = async (accountID: number) => {
}

const accountSelected = async (account: Account, accountType: string) => {
hideManageAccountView();
hideAboutView();

try {
Expand Down Expand Up @@ -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;
};
Expand All @@ -178,7 +157,6 @@ const aboutClicked = async () => {
};

const signInClicked = async () => {
localStorage.setItem('manageAccountMode', 'manage');
emitter?.emit('show-sign-in');
};

Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -339,9 +314,6 @@ onUnmounted(async () => {
:class="{ 'hide': hideAllAccounts || activeAccountID !== account.id }" @account-selected="accountSelected"
@on-remove-clicked="removeAccount(account.id)" />

<!-- Manay my Cyd account -->
<ManageAccountView :should-show="showManageAccount" @redirect-to-account="redirectToAccount" />

<!-- About -->
<AboutView :should-show="showAbout" />
</div>
Expand Down
10 changes: 6 additions & 4 deletions src/renderer/src/views/x/AccountXView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -480,7 +482,7 @@ onUnmounted(async () => {
<XWizardCheckPremium v-if="model.state == State.WizardCheckPremiumDisplay" :model="unref(model)"
:user-authenticated="userAuthenticated" :user-premium="userPremium"
@set-state="setState($event)" @update-account="updateAccount"
@start-jobs-just-save="startJobsJustSave" />
@start-jobs-just-save="startJobsJustSave" @update-user-premium="updateUserPremium" />

<XFinishedRunningJobsPage v-if="model.state == State.FinishedRunningJobsDisplay"
:model="unref(model)"
Expand Down
Loading
Loading