diff --git a/app/assets/js/scripts/loginOptions.js b/app/assets/js/scripts/loginOptions.js index 7ac40abb..5d4d6fc0 100644 --- a/app/assets/js/scripts/loginOptions.js +++ b/app/assets/js/scripts/loginOptions.js @@ -1,10 +1,21 @@ +const loginOptionsCancelContainer = document.getElementById('loginOptionCancelContainer') const loginOptionMicrosoft = document.getElementById('loginOptionMicrosoft') const loginOptionMojang = document.getElementById('loginOptionMojang') +let loginOptionsCancellable = false + let loginOptionsViewOnLoginSuccess let loginOptionsViewOnLoginCancel let loginOptionsViewOnCancel +function loginOptionsCancelEnabled(val){ + if(val){ + $(loginOptionsCancelContainer).show() + } else { + $(loginOptionsCancelContainer).hide() + } +} + loginOptionMicrosoft.onclick = (e) => { switchView(getCurrentView(), VIEWS.waiting, 500, 500, () => { ipcRenderer.send( @@ -21,4 +32,4 @@ loginOptionMojang.onclick = (e) => { loginViewOnCancel = loginOptionsViewOnLoginCancel loginCancelEnabled(true) }) -} \ No newline at end of file +} diff --git a/app/assets/js/scripts/settings.js b/app/assets/js/scripts/settings.js index 7cb8e6c1..119c026b 100644 --- a/app/assets/js/scripts/settings.js +++ b/app/assets/js/scripts/settings.js @@ -445,7 +445,6 @@ function bindAuthAccountLogOut(){ setOverlayHandler(() => { processLogOut(val, isLastAccount) toggleOverlay(false) - switchView(getCurrentView(), VIEWS.login) }) setDismissHandler(() => { toggleOverlay(false) @@ -476,7 +475,6 @@ function processLogOut(val, isLastAccount){ switchView(getCurrentView(), VIEWS.waiting, 500, 500, () => { ipcRenderer.send(MSFT_OPCODE.OPEN_LOGOUT, uuid, isLastAccount) }) - // TODO ADD LOGIC FOR LAST ACCOUNT - SAME AS SOLUTION FOR FIRST TIME LOGIN! } else { AuthManager.removeMojangAccount(uuid).then(() => { if(!isLastAccount && uuid === prevSelAcc.uuid){ @@ -485,6 +483,12 @@ function processLogOut(val, isLastAccount){ updateSelectedAccount(selAcc) validateSelectedAccount() } + if(isLastAccount) { + loginOptionsCancelEnabled(false) + loginOptionsViewOnLoginSuccess = VIEWS.settings + loginOptionsViewOnLoginCancel = VIEWS.loginOptions + switchView(getCurrentView(), VIEWS.loginOptions) + } }) $(parent).fadeOut(250, () => { parent.remove() @@ -530,13 +534,21 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGOUT, (_, ...arguments_) => { updateSelectedAccount(selAcc) validateSelectedAccount() } + if(isLastAccount) { + loginOptionsCancelEnabled(false) + loginOptionsViewOnLoginSuccess = VIEWS.settings + loginOptionsViewOnLoginCancel = VIEWS.loginOptions + switchView(getCurrentView(), VIEWS.loginOptions) + } if(msAccDomElementCache) { msAccDomElementCache.remove() msAccDomElementCache = null } }) .finally(() => { - switchView(getCurrentView(), VIEWS.settings, 500, 500) + if(!isLastAccount) { + switchView(getCurrentView(), VIEWS.settings, 500, 500) + } }) } diff --git a/app/assets/js/scripts/welcome.js b/app/assets/js/scripts/welcome.js index 75b7a74b..ed0399c3 100644 --- a/app/assets/js/scripts/welcome.js +++ b/app/assets/js/scripts/welcome.js @@ -2,6 +2,7 @@ * Script for welcome.ejs */ document.getElementById('welcomeButton').addEventListener('click', e => { + loginOptionsCancelEnabled(false) // False by default, be explicit. loginOptionsViewOnLoginSuccess = VIEWS.landing loginOptionsViewOnLoginCancel = VIEWS.loginOptions switchView(VIEWS.welcome, VIEWS.loginOptions)