Fix auth verification flow and alert ID fallback
This commit is contained in:
Vendored
+18
-11
@@ -30,20 +30,25 @@ export function bootstrapApp() {
|
||||
outlet: document.querySelector('#route-view'),
|
||||
});
|
||||
|
||||
function applyKitchens(kitchens) {
|
||||
store.setKitchens(kitchens);
|
||||
if (!store.activeKitchen && kitchens.length) {
|
||||
store.setActiveKitchen(kitchens[0]);
|
||||
}
|
||||
return kitchens;
|
||||
}
|
||||
|
||||
window.__loncApp = {
|
||||
navigate,
|
||||
async refreshKitchens() {
|
||||
const kitchens = await listKitchens(store);
|
||||
store.setKitchens(kitchens);
|
||||
if (!store.activeKitchen && kitchens.length) {
|
||||
store.setActiveKitchen(kitchens[0]);
|
||||
}
|
||||
return kitchens;
|
||||
return applyKitchens(await listKitchens(store));
|
||||
},
|
||||
async restoreSession() {
|
||||
try {
|
||||
await restoreSession(store);
|
||||
if (store.isConnected) {
|
||||
const result = await restoreSession(store);
|
||||
if (result?.kitchens) {
|
||||
applyKitchens(result.kitchens);
|
||||
} else if (store.isConnected) {
|
||||
await window.__loncApp.refreshKitchens();
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -53,11 +58,13 @@ export function bootstrapApp() {
|
||||
}
|
||||
},
|
||||
async verifyConnection() {
|
||||
await verifyConnection(store);
|
||||
if (store.isConnected) {
|
||||
const result = await verifyConnection(store);
|
||||
if (result?.kitchens) {
|
||||
applyKitchens(result.kitchens);
|
||||
} else if (store.isConnected) {
|
||||
await window.__loncApp.refreshKitchens();
|
||||
}
|
||||
return store.session;
|
||||
return result;
|
||||
},
|
||||
async logout() {
|
||||
await logout(store);
|
||||
|
||||
Reference in New Issue
Block a user