@samitouri / QOSami-HFS / commits / 8870d0b4

plugins: new event: uriChanged

Massimo Melina committed Feb 14, 2024 at 22:43 UTC 8870d0b4b8e13f2c791b4b64b55a9a91b64eb6c7
2 files changed +5 -1
dev-plugins.md
+3
@@ -309,6 +309,8 @@ This is a list of available frontend-events, with respective object parameter an
309 - `userPanelAfterInfo`
310 - no parameter
311 - output `Html`
312 +- `uriChanged`
313 + - parameter `{ uri: string, previous: string }`
314
315 ## Other files
316
@@ -390,6 +392,7 @@ Eg: `HFS.t('filter_count', {n:filteredVariable}, "{n} filtered")`
392
393 - 8.7 (v0.52.0)
394 - exposed "misc" functions
395 + - new event: uriChanged
396 - 8.65 (v0.51.0)
397 - plugin's own hfs-lang files
398 - HFS.state.props.can_overwrite
frontend/src/useFetchList.ts
+2 -1
@@ -7,7 +7,7 @@ import _ from 'lodash'
7 import { subscribeKey } from 'valtio/utils'
8 import { useIsMounted } from 'usehooks-ts'
9 import { alertDialog } from './dialog'
10 -import { HTTP_MESSAGES, HTTP_METHOD_NOT_ALLOWED, HTTP_UNAUTHORIZED, LIST, urlParams, waitFor, xlate } from './misc'
10 +import { hfsEvent, HTTP_MESSAGES, HTTP_METHOD_NOT_ALLOWED, HTTP_UNAUTHORIZED, LIST, urlParams, waitFor, xlate } from './misc'
11 import { t } from './i18n'
12 import { useLocation, useNavigate } from 'react-router-dom'
13
@@ -36,6 +36,7 @@ export default function useFetchList() {
36 if (previous !== uri) {
37 state.showFilter = false
38 state.stopSearch?.()
39 + hfsEvent('uriChanged', { uri, previous })
40 }
41 state.searchManuallyInterrupted = false
42 if (previous && previous !== uri && search) {