fix: use upload and download abort signals (#212)

* fix: use upload and download abort signals

* fix: progress trackers

chore: update fm-lib and bee-js

* chore: bump-up fm-lib version
This commit is contained in:
Bálint Ujvári
2026-03-05 16:55:09 +01:00
parent e00918b192
commit 308ec3dcc0
13 changed files with 154 additions and 85 deletions
@@ -210,6 +210,7 @@ export function FileBrowser({ errorMessage, setErrorMessage }: FileBrowserProps)
const [confirmBulkRestore, setConfirmBulkRestore] = useState(false)
const [isRefreshing, setIsRefreshing] = useState(false)
const [pendingCancelUpload, setPendingCancelUpload] = useState<string | null>(null)
const [pendingCancelDownload, setPendingCancelDownload] = useState<string | null>(null)
const q = query.trim().toLowerCase()
const isSearchMode = q.length > 0
@@ -371,6 +372,16 @@ export function FileBrowser({ errorMessage, setErrorMessage }: FileBrowserProps)
setShowError,
])
const handleDownloadClose = (uuid: string) => {
const row = downloadItems.find(i => i.uuid === uuid)
if (row?.status === TransferStatus.Downloading) {
setPendingCancelDownload(uuid)
} else {
cancelOrDismissDownload(uuid)
}
}
const handleUploadClose = (uuid: string) => {
const row = uploadItems.find(i => i.uuid === uuid)
@@ -425,6 +436,18 @@ export function FileBrowser({ errorMessage, setErrorMessage }: FileBrowserProps)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [showContext, pos, contextRef])
useEffect(() => {
isMountedRef.current = true
return () => {
isMountedRef.current = false
if (rafIdRef.current) {
cancelAnimationFrame(rafIdRef.current)
}
}
}, [])
useEffect(() => {
let title = currentDrive?.name || ''
@@ -446,16 +469,6 @@ export function FileBrowser({ errorMessage, setErrorMessage }: FileBrowserProps)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isSearchMode])
useEffect(() => {
return () => {
isMountedRef.current = false
if (rafIdRef.current) {
cancelAnimationFrame(rafIdRef.current)
}
}
}, [])
const doRefresh = async () => {
handleCloseContext()
@@ -610,6 +623,14 @@ export function FileBrowser({ errorMessage, setErrorMessage }: FileBrowserProps)
}
}}
onCancelUploadCancel={() => setPendingCancelUpload(null)}
pendingCancelDownload={pendingCancelDownload}
onCancelDownloadConfirm={() => {
if (pendingCancelDownload) {
cancelOrDismissDownload(pendingCancelDownload)
setPendingCancelDownload(null)
}
}}
onCancelDownloadCancel={() => setPendingCancelDownload(null)}
/>
{isRefreshing && (
@@ -644,7 +665,7 @@ export function FileBrowser({ errorMessage, setErrorMessage }: FileBrowserProps)
type={FileTransferType.Download}
open={isDownloading}
items={downloadItems}
onRowClose={(name: string) => cancelOrDismissDownload(name)}
onRowClose={handleDownloadClose}
onCloseAll={() => dismissAllDownloads()}
/>
<NotificationBar setErrorMessage={setErrorMessage} />