stash
This commit is contained in:
parent
8f3236b5b4
commit
2afc6308e2
2 changed files with 12 additions and 6 deletions
|
|
@ -63,6 +63,11 @@ const EXPANDED_ROUTE_BUILDERS = {
|
||||||
workflow: ({workflow_id}) => `/workflows/${workflow_id}`,
|
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}) {
|
export function expandedRoute({kind, ...fields}) {
|
||||||
const buildRoute = EXPANDED_ROUTE_BUILDERS[kind];
|
const buildRoute = EXPANDED_ROUTE_BUILDERS[kind];
|
||||||
return buildRoute ? buildRoute(fields) : null;
|
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}`
|
redirect: to => `/inventory/${to.params.handle}/${to.params.id}`
|
||||||
}, {
|
}, {
|
||||||
path: '/:short_id',
|
path: '/:short_id',
|
||||||
redirect: to => {
|
redirect: async to => {
|
||||||
console.log(to)
|
|
||||||
const p = deserializeShortId(decodeShortId(to.params.short_id))
|
const p = deserializeShortId(decodeShortId(to.params.short_id))
|
||||||
console.log(p)
|
if (NEEDS_IDMAP.has(p.kind) && !store.state.idmapLoaded) {
|
||||||
const url = expandedRoute(p)
|
await store.dispatch('fetchIdMap')
|
||||||
console.log(url)
|
}
|
||||||
return url;
|
return expandedRoute(p);
|
||||||
}
|
}
|
||||||
}, {path: '/inventory/new', component: InventoryNew, meta: {requiresAuth: true}}, {
|
}, {path: '/inventory/new', component: InventoryNew, meta: {requiresAuth: true}}, {
|
||||||
path: '/friends',
|
path: '/friends',
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ export default createStore({
|
||||||
groups: [],
|
groups: [],
|
||||||
groupInvites: [],
|
groupInvites: [],
|
||||||
idmap: {identities: [], groups: []},
|
idmap: {identities: [], groups: []},
|
||||||
|
idmapLoaded: false,
|
||||||
item_map: {},
|
item_map: {},
|
||||||
home_servers: null,
|
home_servers: null,
|
||||||
all_friends_servers: null,
|
all_friends_servers: null,
|
||||||
|
|
@ -115,6 +116,7 @@ export default createStore({
|
||||||
},
|
},
|
||||||
setIdMap(state, idmap) {
|
setIdMap(state, idmap) {
|
||||||
state.idmap = idmap;
|
state.idmap = idmap;
|
||||||
|
state.idmapLoaded = true;
|
||||||
},
|
},
|
||||||
setHomeServers(state, home_servers) {
|
setHomeServers(state, home_servers) {
|
||||||
state.home_servers = home_servers;
|
state.home_servers = home_servers;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue