fix: resolve queue management and metadata fetch bugs

- Reset isRemoving state in DeleteConfirmationModal on open and close to prevent UI freeze
- Filter sidebar queue count to exclude completed downloads
- Return fully resolved URL from backend metadata fetch to avoid 403s on one-time tokens
This commit is contained in:
NimBold
2026-06-21 14:57:21 +03:30
parent 3660ceb47a
commit d535bdac8f
5 changed files with 14 additions and 5 deletions
+2 -1
View File
@@ -16,6 +16,7 @@ use std::time::{Duration, Instant};
#[derive(Serialize, TS)]
#[ts(export, export_to = "../../src/bindings/")]
pub struct MetadataResponse {
url: String,
filename: String,
size: String,
#[ts(type = "number")]
@@ -849,7 +850,7 @@ async fn fetch_metadata(url: String, user_agent: Option<String>, username: Optio
}
}
Ok(MetadataResponse { filename, size: size_str, size_bytes })
Ok(MetadataResponse { url: current_url, filename, size: size_str, size_bytes })
}
const MEDIA_METADATA_CACHE_TTL: Duration = Duration::from_secs(60);
+1 -1
View File
@@ -1,3 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type MetadataResponse = { filename: string, size: string, size_bytes: number, };
export type MetadataResponse = { url: string, filename: string, size: string, size_bytes: number, };
+1 -1
View File
@@ -264,7 +264,7 @@ export const AddDownloadsModal = () => {
password: keychainPassword
});
updatedItems[i] = {
url,
url: meta.url || url,
file: lines.length === 1 && pendingAddFilename ? pendingAddFilename : meta.filename,
size: meta.size,
sizeBytes: meta.size_bytes,
+9 -1
View File
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { useDownloadStore } from '../store/useDownloadStore';
import { AlertTriangle } from 'lucide-react';
@@ -7,6 +7,13 @@ export const DeleteConfirmationModal: React.FC = () => {
const [errorMessage, setErrorMessage] = useState('');
const [isRemoving, setIsRemoving] = useState(false);
useEffect(() => {
if (deleteModalState.isOpen) {
setIsRemoving(false);
setErrorMessage('');
}
}, [deleteModalState.isOpen]);
if (!deleteModalState.isOpen) return null;
const handleCancel = () => {
@@ -38,6 +45,7 @@ export const DeleteConfirmationModal: React.FC = () => {
setIsRemoving(false);
return;
}
setIsRemoving(false);
closeDeleteModal();
};
+1 -1
View File
@@ -54,7 +54,7 @@ export const Sidebar: React.FC<SidebarProps> = (props) => {
const getCount = (filter: SidebarFilter) => {
if (filter.startsWith('queue:')) {
const qid = filter.replace('queue:', '');
return downloads.filter(d => d.queueId === qid).length;
return downloads.filter(d => d.queueId === qid && d.status !== 'completed').length;
}
switch (filter) {
case 'all': return downloads.length;