better code: typing
Massimo Melina committed
Jun 16, 2023 at 15:27 UTC
b135842505266c3578c24b400596ff756e8e7f05
5 files changed
+7
-7
frontend/src/Breadcrumbs.ts
+1
-1
@@ -40,7 +40,7 @@ function Breadcrumb({ path, label, current }:{ current?: boolean, path: string,
40
if (!current) return
41
if (typeof label !== 'string')
42
return reload()
43
- openFileMenu(new DirEntry(path), ev as any as MouseEvent, [
43
+ openFileMenu(new DirEntry(path), ev, [
44
{
45
label: t`Reload`,
46
icon: 'reload',
frontend/src/BrowseFiles.ts
+1
@@ -5,6 +5,7 @@ import {
5
createElement as h,
6
Fragment,
7
memo,
8
+ MouseEvent,
9
useCallback,
10
useEffect,
11
useMemo,
frontend/src/components.ts
+2
-2
@@ -9,7 +9,7 @@ import {
9
Fragment,
10
HTMLAttributes,
11
InputHTMLAttributes,
12
- isValidElement,
12
+ isValidElement, MouseEventHandler,
13
ReactNode,
14
useMemo
15
} from 'react'
@@ -85,7 +85,7 @@ export function CustomCode({ name, props, ifEmpty }: { name: string, props?: any
85
}
86
87
interface IconBtnOptions extends ButtonHTMLAttributes<any> { small?: boolean, style?: any }
88
-export function iconBtn(icon: string, onClick: () => any, { small=true, style={}, ...props }: IconBtnOptions={}) {
88
+export function iconBtn(icon: string, onClick: MouseEventHandler, { small=true, style={}, ...props }: IconBtnOptions={}) {
89
return h('button', {
90
onClick,
91
...props,
frontend/src/fileMenu.ts
+1
-1
@@ -1,6 +1,6 @@
1
import { t, useI18N } from './i18n'
2
import { dontBotherWithKeys, formatBytes, hfsEvent, hIcon, newDialog } from './misc'
3
-import { createElement as h, Fragment, isValidElement, MouseEventHandler, ReactNode } from 'react'
3
+import { createElement as h, Fragment, isValidElement, MouseEventHandler, MouseEvent, ReactNode } from 'react'
4
import _ from 'lodash'
5
import { getEntryIcon, MISSING_PERM } from './BrowseFiles'
6
import { DirEntry, state } from './state'
src/upload.ts
+2
-3
@@ -14,7 +14,6 @@ import { defineConfig } from './config'
14
import { getFreeDiskSync } from './util-os'
15
import { socket2connection, updateConnection } from './connections'
16
import { roundSpeed } from './throttler'
17
-import _ from 'lodash'
17
18
export const deleteUnfinishedUploadsAfter = defineConfig<undefined|number>('delete_unfinished_uploads_after', 86_400)
19
export const minAvailableMb = defineConfig('min_available_mb', 100)
@@ -36,10 +35,10 @@ export function uploadWriter(base: VfsNode, path: string, ctx: Koa.Context) {
35
const free = getFreeDiskSync(dir)
36
if (typeof free !== 'number' || isNaN(free))
37
throw ''
39
- if (reqSize > getFreeDiskSync(dir) - (min || 0))
38
+ if (reqSize > free - (min || 0))
39
return fail(HTTP_PAYLOAD_TOO_LARGE)
40
}
42
- catch(e: any) {
41
+ catch(e: any) { // warn, but let it through
42
console.warn("can't check disk size:", e.message || String(e))
43
}
44
if (ctx.query.skipExisting && fs.existsSync(fullPath))