better code: clearer var name
Massimo Melina committed
Feb 13, 2024 at 21:44 UTC
3073c1a64b54cdd99f32c2369e7444d91c1cf275
5 files changed
+8
-9
frontend/src/BrowseFiles.ts
+2
-2
@@ -54,7 +54,7 @@ export function BrowseFiles() {
54
}
55
56
function FilesList() {
57
- const { filteredList, list, loading, stoppedSearch } = useSnapState()
57
+ const { filteredList, list, loading, searchManuallyInterrupted } = useSnapState()
58
const midnight = useMidnight() // as an optimization we calculate this only once per list and pass it down
59
const pageSize = 100
60
const [page, setPage] = useState(0)
@@ -109,7 +109,7 @@ function FilesList() {
109
110
const {t} = useI18N()
111
112
- const msgInstead = !list.length ? (!loading && (stoppedSearch ? t('stopped_before', "Stopped before finding anything") : t('empty_list', "Nothing here")))
112
+ const msgInstead = !list.length ? (!loading && (searchManuallyInterrupted ? t('stopped_before', "Stopped before finding anything") : t('empty_list', "Nothing here")))
113
: filteredList && !filteredList.length && t('filter_none', "No match for this filter")
114
115
return h(Fragment, {},
frontend/src/Head.ts
+2
-2
@@ -20,7 +20,7 @@ export function Head() {
20
}
21
22
function FolderStats() {
23
- const { list, loading, stoppedSearch } = useSnapState()
23
+ const { list, loading, searchManuallyInterrupted } = useSnapState()
24
const { files, folders, size } = useMemo(() => {
25
let files = 0, folders = 0, size = 0
26
for (const { isFolder, s } of list) {
@@ -35,7 +35,7 @@ function FolderStats() {
35
const { t } = useI18N()
36
return h(Fragment, {},
37
h('div', { id:'folder-stats' },
38
- stoppedSearch ? hIcon('interrupted', { title: t`Search was interrupted` })
38
+ searchManuallyInterrupted ? hIcon('interrupted', { title: t`Search was interrupted` })
39
: list.length>0 && loading && h(Spinner),
40
[
41
files && t('n_files', { n: files }, '{n,plural,one{# file} other{# files}}'),
frontend/src/menu.ts
+3
-3
@@ -18,7 +18,7 @@ import { cut } from './clip'
18
import { Btn, BtnProps } from './components'
19
20
export function MenuPanel() {
21
- const { showFilter, remoteSearch, stopSearch, stoppedSearch, selected, props } = useSnapState()
21
+ const { showFilter, remoteSearch, stopSearch, searchManuallyInterrupted, selected, props } = useSnapState()
22
const { can_upload, can_delete, can_archive } = props ? { ...defaultPerms, ...props } : {} as VfsPerms
23
const { uploading, qs } = useSnapshot(uploadState)
24
useEffect(() => {
@@ -115,7 +115,7 @@ export function MenuPanel() {
115
}),
116
),
117
remoteSearch && h('div', { id: 'searched' },
118
- (stopSearch ? t`Searching` : t`Searched`) + ': ' + remoteSearch + prefix(' (', stoppedSearch && t`interrupted`, ')')),
118
+ (stopSearch ? t`Searching` : t`Searched`) + ': ' + remoteSearch + prefix(' (', searchManuallyInterrupted && t`interrupted`, ')')),
119
)
120
121
function getSearchProps() {
@@ -126,7 +126,7 @@ export function MenuPanel() {
126
className: 'ani-working',
127
onClick() {
128
stopSearch()
129
- state.stoppedSearch = true
129
+ state.searchManuallyInterrupted = true
130
}
131
} : state.remoteSearch && !stopSearch ? {
132
id: 'search-clear-button',
frontend/src/state.ts
+1
-1
@@ -7,7 +7,7 @@ import { FRONTEND_OPTIONS, getHFS, hIcon, objSameKeys, pathEncode, typedKeys } f
7
8
export const state = proxy<typeof FRONTEND_OPTIONS & {
9
stopSearch?: ()=>void,
10
- stoppedSearch?: boolean,
10
+ searchManuallyInterrupted?: boolean,
11
iconsReady: boolean,
12
username: string,
13
accountExp?: string,
frontend/src/useFetchList.ts
-1
@@ -61,7 +61,6 @@ 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
64
const src = apiEvents('get_file_list', params, (type, data) => {
65
if (!isMounted()) return
66
switch (type) {