plugins: new state 'uri' instead of uriChanged
Massimo Melina committed
Mar 31, 2024 at 12:28 UTC
acb3d6082d3746aad8e419b64cc675ab8833d481
3 files changed
+5
-1
dev-plugins.md
+1
@@ -312,6 +312,7 @@ This is a list of available frontend-events, with respective object parameter an
312
- no parameter
313
- output `Html`
314
- `uriChanged`
315
+ - DEPRECATED: use `watchState('uri', callback)` instead.
316
- parameter `{ uri: string, previous: string }`
317
318
## Other files
frontend/src/state.ts
+2
@@ -34,7 +34,9 @@ export const state = proxy<typeof FRONTEND_OPTIONS & {
34
comment?: string
35
}
36
canChangePassword: boolean
37
+ uri: string
38
}>({
39
+ uri: '',
40
canChangePassword: false,
41
props: {},
42
...objSameKeys(FRONTEND_OPTIONS, (v,k) => getHFS()[k] ?? v),
frontend/src/useFetchList.ts
+2
-1
@@ -34,9 +34,10 @@ export default function useFetchList() {
34
const previous = lastUri.current
35
lastUri.current = uri
36
if (previous !== uri) {
37
+ state.uri = uri // this should be a better way than uriChanged
38
state.showFilter = false
39
state.stopSearch?.()
39
- hfsEvent('uriChanged', { uri, previous })
40
+ hfsEvent('uriChanged', { uri, previous }) // legacy pre-0.52, remove in 0.54
41
}
42
state.searchManuallyInterrupted = false
43
if (previous && previous !== uri && search) {