From 2afc6308e269b77df0f9ec72151ffddc1c5059eb Mon Sep 17 00:00:00 2001 From: jedi Date: Mon, 24 Aug 2026 11:35:18 +0200 Subject: [PATCH] stash --- frontend/src/router.js | 16 ++++++++++------ frontend/src/store.js | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/frontend/src/router.js b/frontend/src/router.js index b355620..abeea2c 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -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', diff --git a/frontend/src/store.js b/frontend/src/store.js index cd61ff3..364d771 100644 --- a/frontend/src/store.js +++ b/frontend/src/store.js @@ -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;