optimize open database calls

This commit is contained in:
Adrian Zürcher
2026-02-23 21:23:14 +01:00
parent ec5893db57
commit fa58872840
15 changed files with 133 additions and 155 deletions

View File

@@ -5,6 +5,7 @@ import { i18n } from 'boot/lang';
import type { Roles } from 'src/vueLib/models/roles';
import { useUserStore } from 'src/vueLib/login/userStore';
import { useLogin } from 'src/vueLib/login/useLogin';
import { Me } from 'src/vueLib/components/DatabaseCall';
export const roles = ref<Roles>([]);
@@ -64,21 +65,27 @@ export function useRoleTable() {
.finally(() => {
loading.value = false;
});
await appApi
.get('/login/me')
.then((resp) => {
userStore
.setUser({
id: resp.data.id,
user: resp.data.user,
role: { role: resp.data.role, permissions: [] },
})
.catch((err) => NotifyResponse(err, 'error'));
login.refresh().catch((err) => NotifyResponse(err, 'error'));
})
.catch(() => {
login.logout().catch((err) => NotifyResponse(err, 'error'));
const resp = await Me().catch(() => {
login.logout().catch((err) => {
NotifyResponse(err, 'error');
return;
});
});
if (!resp) return;
await userStore
.setUser({
id: resp.data.id,
user: resp.data.user,
role: { role: resp.data.role, permissions: [] },
workspaceId: resp.data.workspaceId,
settings: resp.data.settings,
})
.catch((err) => NotifyResponse(err, 'error'));
login.refresh().catch((err) => NotifyResponse(err, 'error'));
}
return {
roles,