plugins: async onDirEntry
Massimo Melina committed
Sep 19, 2023 at 15:13 UTC
3a0231c9ba6e49e530ccde5e4cd2ba16eb9a69a9
2 files changed
+5
-3
dev-plugins.md
+3
-2
@@ -92,7 +92,7 @@ used must be strictly JSON (thus, no single quotes, only double quotes for strin
92
If you want to execute something in the "upstream" of middlewares, return a function.
93
94
- `unload: function` called when unloading a plugin. This is a good place for example to clearInterval().
95
-- `onDirEntry: ({ entry: DirEntry, listUri: string }) => void | false` by providing this callback you can manipulate the record
95
+- `onDirEntry: ({ entry: DirEntry, listUri: string }) => Promisable<void | false>` by providing this callback you can manipulate the record
96
that is sent to the frontend (`entry`), or you can return false to exclude this entry from the results.
97
- `config: { [key]: FieldDescriptor }` declare a set of admin-configurable values owned by the plugin
98
that will be displayed inside Admin-panel for change. Each property is identified by its key,
@@ -358,7 +358,8 @@ Where `h` is just `import { createElement as h } from 'react'`.
358
359
## API version history
360
361
-- 8.4 (v0.48.2)
361
+- 8.4 (v0.49.0)
362
+ - exports.onDirEntry: support async
363
- HFS.fileShow
364
- api.Const (api.const is now deprecated)
365
- 8.3 (v0.47.0)
src/api.file_list.ts
+2
-1
@@ -74,7 +74,8 @@ export const get_file_list: ApiHandler = async ({ uri, offset, limit, search, c
74
continue
75
const cbParams = { entry, ctx, listUri: uri, node: sub }
76
try {
77
- if (onDirEntryHandlers.some(cb => cb(cbParams) === false))
77
+ const res = await Promise.all(onDirEntryHandlers.map(cb => cb(cbParams)))
78
+ if (res.some(x => x === false))
79
continue
80
}
81
catch(e) {