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 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)
})
}
}

View File

@ -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)
}
})
}

View File

@ -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)