Fix: file-manager and swarm-desktop bugs (#714)

- drive capacity display with stamp polling
- download/upload progress handling
- overlay and tooltip issues
- FileMaganger readme
- ultra-light mode handling
- account feed view page
- download media files
- remove not found syncing link
- fix ultra light node wallet page
- tooltip issues
---------
Co-authored-by: Andrei Mitrea <andrei.mitrea.hq@gmail.com>
Co-authored-by: nidishk <nidishkrishnan45@gmail.com>
Co-authored-by: Ferenc Sárai <sarai.ferenc@gmail.com>
Co-authored-by: Nándor Komlódi <nandor.komlodi@gmail.com>
Co-authored-by: rolandlor <33499567+rolandlor@users.noreply.github.com>
This commit is contained in:
Bálint Ujvári
2026-01-26 12:57:14 +01:00
committed by GitHub
parent ecadafd21d
commit 0d5138f5bc
78 changed files with 3961 additions and 1194 deletions
+88 -15
View File
@@ -1,29 +1,54 @@
import { useCallback, useMemo, useRef, useState, useContext } from 'react'
import { useCallback, useMemo, useRef, useState, useContext, useEffect } from 'react'
import type { FileInfo } from '@solarpunkltd/file-manager-lib'
import { PostageBatch } from '@ethersphere/bee-js'
import { Context as FMContext } from '../../../providers/FileManager'
import { Context as SettingsContext } from '../../../providers/Settings'
import { startDownloadingQueue } from '../utils/download'
import { formatBytes, getFileId } from '../utils/common'
import { formatBytes, getFileId, safeSetState } from '../utils/common'
import { DownloadProgress, TrackDownloadProps } from '../constants/transfers'
import { getUsableStamps } from '../utils/bee'
import { performBulkFileOperation, FileOperation } from '../utils/fileOperations'
import { uuidV4 } from '../../../utils'
export function useBulkActions(opts: {
interface BulkOptions {
listToRender: FileInfo[]
trackDownload: (props: TrackDownloadProps) => (dp: DownloadProgress) => void
}) {
const { listToRender, trackDownload } = opts
setErrorMessage?: (error: string) => void
}
const { fm } = useContext(FMContext)
export function useBulkActions({ listToRender, setErrorMessage, trackDownload }: BulkOptions) {
const { fm, adminDrive, drives, refreshStamp, setShowError } = useContext(FMContext)
const { beeApi } = useContext(SettingsContext)
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set())
const [driveStamps, setDriveStamps] = useState<PostageBatch[] | undefined>(undefined)
const allIds = useMemo(() => listToRender.map(getFileId), [listToRender])
const selectedCount = useMemo(() => allIds.filter(id => selectedIds.has(id)).length, [allIds, selectedIds])
const allChecked = useMemo(() => allIds.length > 0 && selectedCount === allIds.length, [allIds.length, selectedCount])
const someChecked = useMemo(() => selectedCount > 0 && !allChecked, [selectedCount, allChecked])
const isMountedRef = useRef(true)
const fileInputRef = useRef<HTMLInputElement | null>(null)
const selectedFiles = useMemo(
() => listToRender.filter(fi => selectedIds.has(getFileId(fi))),
[listToRender, selectedIds],
)
useEffect(() => {
isMountedRef.current = true
const getStamps = async () => {
const stamps = await getUsableStamps(beeApi)
const stampList = stamps.filter(s => drives.some(d => d.batchId.toString() === s.batchID.toString()))
safeSetState(isMountedRef, setDriveStamps)(stampList)
}
getStamps()
return () => {
isMountedRef.current = false
}
}, [beeApi, drives])
const toggleOne = useCallback((fi: FileInfo, checked: boolean) => {
const id = getFileId(fi)
@@ -56,45 +81,93 @@ export function useBulkActions(opts: {
const rawSize = fi.customMetadata?.size as string | number | undefined
const prettySize = formatBytes(rawSize)
const expected = rawSize ? Number(rawSize) : undefined
const tracker = trackDownload({ name: fi.name, size: prettySize, expectedSize: expected })
const driveName = drives.find(d => d.id.toString() === fi.driveId.toString())?.name
const tracker = trackDownload({
uuid: uuidV4(),
name: fi.name,
size: prettySize,
expectedSize: expected,
driveName,
})
trackers.push(tracker)
}
await startDownloadingQueue(fm, list, trackers)
},
[fm, trackDownload],
[fm, trackDownload, drives],
)
const bulkTrash = useCallback(
async (list: FileInfo[]) => {
if (!fm || !list?.length) return
await Promise.allSettled(list.map(f => fm.trashFile(f)))
await performBulkFileOperation({
fm,
files: list,
operation: FileOperation.Trash,
stamps: driveStamps || [],
onError: error => {
setErrorMessage?.(error)
setShowError(true)
},
onFileComplete: file => {
refreshStamp(file.batchId.toString())
},
})
clearAll()
},
[fm, clearAll],
[fm, driveStamps, clearAll, refreshStamp, setErrorMessage, setShowError],
)
const bulkRestore = useCallback(
async (list: FileInfo[]) => {
if (!fm || !list?.length) return
await Promise.allSettled(list.map(f => fm.recoverFile(f)))
await performBulkFileOperation({
fm,
files: list,
operation: FileOperation.Recover,
stamps: driveStamps || [],
onError: error => {
setErrorMessage?.(error)
setShowError(true)
},
onFileComplete: file => {
refreshStamp(file.batchId.toString())
},
})
clearAll()
},
[fm, clearAll],
[fm, driveStamps, refreshStamp, clearAll, setErrorMessage, setShowError],
)
const bulkForget = useCallback(
async (list: FileInfo[]) => {
if (!fm || !list?.length) return
if (!fm || !fm.adminStamp || !adminDrive || !list?.length) return
await Promise.allSettled(list.map(f => fm.forgetFile(f)))
await performBulkFileOperation({
fm,
files: list,
operation: FileOperation.Forget,
stamps: driveStamps || [],
adminStamp: fm.adminStamp,
adminDrive: adminDrive || undefined,
onError: error => {
setErrorMessage?.(error)
setShowError(true)
},
onFileComplete: () => {
if (fm.adminStamp) {
refreshStamp(fm.adminStamp.batchID.toString())
}
},
})
clearAll()
},
[fm, clearAll],
[fm, adminDrive, driveStamps, clearAll, refreshStamp, setErrorMessage, setShowError],
)
return useMemo(