This commit is contained in:
j3d1 2026-08-24 11:35:18 +02:00
parent 8f3236b5b4
commit 2afc6308e2
2 changed files with 12 additions and 6 deletions

View file

@ -63,6 +63,11 @@ const EXPANDED_ROUTE_BUILDERS = {
workflow: ({workflow_id}) => `/workflows/${workflow_id}`,
};
// Only these two builders read identityHandleById/groupHandleById (derived from state.idmap) -
// gate the cold-open fetch on kind so a storage_location/group/workflow/file short id never waits
// on an unrelated network call.
const NEEDS_IDMAP = new Set(['item', 'group_item']);
export function expandedRoute({kind, ...fields}) {
const buildRoute = EXPANDED_ROUTE_BUILDERS[kind];
return buildRoute ? buildRoute(fields) : null;
@ -97,13 +102,12 @@ const routes = [{path: '/', component: Dashboard, meta: {requiresAuth: true}}, {
redirect: to => `/inventory/${to.params.handle}/${to.params.id}`
}, {
path: '/:short_id',
redirect: to => {
console.log(to)
redirect: async to => {
const p = deserializeShortId(decodeShortId(to.params.short_id))
console.log(p)
const url = expandedRoute(p)
console.log(url)
return url;
if (NEEDS_IDMAP.has(p.kind) && !store.state.idmapLoaded) {
await store.dispatch('fetchIdMap')
}
return expandedRoute(p);
}
}, {path: '/inventory/new', component: InventoryNew, meta: {requiresAuth: true}}, {
path: '/friends',

View file

@ -75,6 +75,7 @@ export default createStore({
groups: [],
groupInvites: [],
idmap: {identities: [], groups: []},
idmapLoaded: false,
item_map: {},
home_servers: null,
all_friends_servers: null,
@ -115,6 +116,7 @@ export default createStore({
},
setIdMap(state, idmap) {
state.idmap = idmap;
state.idmapLoaded = true;
},
setHomeServers(state, home_servers) {
state.home_servers = home_servers;