Enhance upload functionality in UploadStore and UI: implement retry mechanism for failed uploads, allowing users to manually retry uploads from the UploadSnackbar. Update translations to include retry options and improve error handling for transient issues during media uploads.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { AlertCircle, Check, ChevronDown, ChevronUp, Clock, Loader2, X } from 'lucide-react'
|
||||
import { AlertCircle, Check, ChevronDown, ChevronUp, Clock, Loader2, RotateCw, X } from 'lucide-react'
|
||||
import { cn } from '@/shared/lib/cn'
|
||||
import { type UploadItem, useUploadStore } from './upload-store'
|
||||
|
||||
@@ -25,7 +25,7 @@ function barWidth(item: UploadItem): number {
|
||||
/** Глобальный индикатор загрузок: живёт вне страниц, поэтому загрузка идёт при любой навигации. */
|
||||
export function UploadSnackbar() {
|
||||
const { t } = useTranslation()
|
||||
const { items, active, minimized, skipped, toggleMinimize, dismiss, cancel, cancelAll } =
|
||||
const { items, active, minimized, skipped, toggleMinimize, dismiss, cancel, cancelAll, retry } =
|
||||
useUploadStore()
|
||||
|
||||
if (items.length === 0 && skipped === 0) return null
|
||||
@@ -103,6 +103,16 @@ export function UploadSnackbar() {
|
||||
<X className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
)}
|
||||
{item.status === 'error' && (
|
||||
<button
|
||||
type="button"
|
||||
className="ml-auto shrink-0 opacity-70 hover:opacity-100"
|
||||
title={t('common.retry')}
|
||||
onClick={() => retry(item.id)}
|
||||
>
|
||||
<RotateCw className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<div className="h-1 w-full overflow-hidden rounded bg-muted">
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user