handle cases where navigation (breadcrumbs) brings you to a node with 'default'
Massimo Melina committed
Dec 24, 2021 at 18:31 UTC
ccae6abf1536165b335ecf56201aa6a5b6191297
2 files changed
+6
frontend/src/useFetchList.ts
+4
@@ -73,6 +73,10 @@ export default function useFetchList() {
73
|| Error()
74
if (res instanceof Error)
75
return setError(res)
76
+ if (res.redirect) {
77
+ window.history.back() // cancel last piece of navigation that brought us here, we'll replace it with the following
78
+ loc.href = res.redirect
79
+ }
80
const chunk = res.list
81
setList(list = [ ...list, ...chunk ])
82
if (chunk.length < limit)
src/apis.ts
+2
@@ -45,6 +45,8 @@ export const frontEndApis: ApiHandlers = {
45
return
46
if (search?.includes('..'))
47
return ctx.throw(400)
48
+ if (node.default)
49
+ return { redirect: path }
50
offset = Number(offset)
51
limit = Number(limit)
52
const re = new RegExp(_.escapeRegExp(search),'i')