Integrate Microsoft login option when no accounts are left after logout.

This commit is contained in:
Daniel Scalzi 2022-02-09 18:23:50 -05:00
parent 8b23847c29
commit d95e85aa40
No known key found for this signature in database
GPG Key ID: 9E3E2AFE45328AA5
3 changed files with 28 additions and 4 deletions

View File

@ -1,10 +1,21 @@
const loginOptionsCancelContainer = document.getElementById('loginOptionCancelContainer')
const loginOptionMicrosoft = document.getElementById('loginOptionMicrosoft') const loginOptionMicrosoft = document.getElementById('loginOptionMicrosoft')
const loginOptionMojang = document.getElementById('loginOptionMojang') const loginOptionMojang = document.getElementById('loginOptionMojang')
let loginOptionsCancellable = false
let loginOptionsViewOnLoginSuccess let loginOptionsViewOnLoginSuccess
let loginOptionsViewOnLoginCancel let loginOptionsViewOnLoginCancel
let loginOptionsViewOnCancel let loginOptionsViewOnCancel
function loginOptionsCancelEnabled(val){
if(val){
$(loginOptionsCancelContainer).show()
} else {
$(loginOptionsCancelContainer).hide()
}
}
loginOptionMicrosoft.onclick = (e) => { loginOptionMicrosoft.onclick = (e) => {
switchView(getCurrentView(), VIEWS.waiting, 500, 500, () => { switchView(getCurrentView(), VIEWS.waiting, 500, 500, () => {
ipcRenderer.send( ipcRenderer.send(

View File

@ -445,7 +445,6 @@ function bindAuthAccountLogOut(){
setOverlayHandler(() => { setOverlayHandler(() => {
processLogOut(val, isLastAccount) processLogOut(val, isLastAccount)
toggleOverlay(false) toggleOverlay(false)
switchView(getCurrentView(), VIEWS.login)
}) })
setDismissHandler(() => { setDismissHandler(() => {
toggleOverlay(false) toggleOverlay(false)
@ -476,7 +475,6 @@ function processLogOut(val, isLastAccount){
switchView(getCurrentView(), VIEWS.waiting, 500, 500, () => { switchView(getCurrentView(), VIEWS.waiting, 500, 500, () => {
ipcRenderer.send(MSFT_OPCODE.OPEN_LOGOUT, uuid, isLastAccount) ipcRenderer.send(MSFT_OPCODE.OPEN_LOGOUT, uuid, isLastAccount)
}) })
// TODO ADD LOGIC FOR LAST ACCOUNT - SAME AS SOLUTION FOR FIRST TIME LOGIN!
} else { } else {
AuthManager.removeMojangAccount(uuid).then(() => { AuthManager.removeMojangAccount(uuid).then(() => {
if(!isLastAccount && uuid === prevSelAcc.uuid){ if(!isLastAccount && uuid === prevSelAcc.uuid){
@ -485,6 +483,12 @@ function processLogOut(val, isLastAccount){
updateSelectedAccount(selAcc) updateSelectedAccount(selAcc)
validateSelectedAccount() validateSelectedAccount()
} }
if(isLastAccount) {
loginOptionsCancelEnabled(false)
loginOptionsViewOnLoginSuccess = VIEWS.settings
loginOptionsViewOnLoginCancel = VIEWS.loginOptions
switchView(getCurrentView(), VIEWS.loginOptions)
}
}) })
$(parent).fadeOut(250, () => { $(parent).fadeOut(250, () => {
parent.remove() parent.remove()
@ -530,13 +534,21 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGOUT, (_, ...arguments_) => {
updateSelectedAccount(selAcc) updateSelectedAccount(selAcc)
validateSelectedAccount() validateSelectedAccount()
} }
if(isLastAccount) {
loginOptionsCancelEnabled(false)
loginOptionsViewOnLoginSuccess = VIEWS.settings
loginOptionsViewOnLoginCancel = VIEWS.loginOptions
switchView(getCurrentView(), VIEWS.loginOptions)
}
if(msAccDomElementCache) { if(msAccDomElementCache) {
msAccDomElementCache.remove() msAccDomElementCache.remove()
msAccDomElementCache = null msAccDomElementCache = null
} }
}) })
.finally(() => { .finally(() => {
switchView(getCurrentView(), VIEWS.settings, 500, 500) if(!isLastAccount) {
switchView(getCurrentView(), VIEWS.settings, 500, 500)
}
}) })
} }

View File

@ -2,6 +2,7 @@
* Script for welcome.ejs * Script for welcome.ejs
*/ */
document.getElementById('welcomeButton').addEventListener('click', e => { document.getElementById('welcomeButton').addEventListener('click', e => {
loginOptionsCancelEnabled(false) // False by default, be explicit.
loginOptionsViewOnLoginSuccess = VIEWS.landing loginOptionsViewOnLoginSuccess = VIEWS.landing
loginOptionsViewOnLoginCancel = VIEWS.loginOptions loginOptionsViewOnLoginCancel = VIEWS.loginOptions
switchView(VIEWS.welcome, VIEWS.loginOptions) switchView(VIEWS.welcome, VIEWS.loginOptions)