support URL?search
Massimo Melina committed
Feb 13, 2024 at 10:15 UTC
baf3a5ad1e0ac5988175df96fb219b9e85d7e859
2 files changed
+12
-6
README.md
+2
-3
@@ -186,10 +186,9 @@ Some actions you can take for improved security:
186
- Appending ?lang=CODE to address will force a specific language
187
- right/ctrl/command click on toggle-all checkbox will invert each checkbox state
188
- Appending `?login=USER:PASSWORD` will automatically log in the browser
189
-- Appending `?overwrite` on uploads, will try override the dont_overwrite_uploading configuration, provided you also have delete permission
189
+- Appending `?overwrite` on uploads, will override the dont_overwrite_uploading configuration, provided you also have delete permission
190
+- Appending `?search=PATTERN` will trigger search at start
191
- Right-click on "check for updates" will let you input a URL of a version to install
191
-- Admin: alt+digit will switch page (ctrl on Mac)
192
-- Appending ?overwrite to the URL of an upload request will overwrite existing file if you have delete permission
192
- shift+click on a file will show & play
193
194
## Contribute
frontend/src/useFetchList.ts
+10
-3
@@ -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, xlate } from './misc'
10
+import { 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
@@ -15,6 +15,12 @@ export function usePath() {
15
return useLocation().pathname
16
}
17
18
+// allow links with ?search
19
+waitFor(() => urlParams).then(x => {
20
+ if (x)
21
+ state.remoteSearch = x.search
22
+})
23
+
24
export default function useFetchList() {
25
const snap = useSnapState()
26
const uri = usePath() // this api can still work removing the initial slash, but then we'll have a mixed situation that will require plugins an extra effort
@@ -31,8 +37,8 @@ export default function useFetchList() {
37
state.showFilter = false
38
state.stopSearch?.()
39
}
34
- state.stoppedSearch = false
35
- if (previous !== uri && search) {
40
+ state.searchManuallyInterrupted = false
41
+ if (previous && previous !== uri && search) {
42
state.remoteSearch = ''
43
return
44
}
@@ -55,6 +61,7 @@ export default function useFetchList() {
61
state.list = sort([...state.list, ...chunk])
62
}
63
const timer = setInterval(flush, 1000)
64
+ state.stopSearch?.() // be sure we don't overlap 2
65
const src = apiEvents('get_file_list', params, (type, data) => {
66
if (!isMounted()) return
67
switch (type) {