Fix auth verification flow and alert ID fallback

This commit is contained in:
2026-04-06 17:07:14 +02:00
parent 1521602743
commit a0da39b697
4 changed files with 56 additions and 23 deletions
+18 -11
View File
@@ -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);