mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-20 16:12:17 +00:00
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:
@@ -16,6 +16,7 @@ use std::time::{Duration, Instant};
|
|||||||
#[derive(Serialize, TS)]
|
#[derive(Serialize, TS)]
|
||||||
#[ts(export, export_to = "../../src/bindings/")]
|
#[ts(export, export_to = "../../src/bindings/")]
|
||||||
pub struct MetadataResponse {
|
pub struct MetadataResponse {
|
||||||
|
url: String,
|
||||||
filename: String,
|
filename: String,
|
||||||
size: String,
|
size: String,
|
||||||
#[ts(type = "number")]
|
#[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);
|
const MEDIA_METADATA_CACHE_TTL: Duration = Duration::from_secs(60);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// 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, };
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ export const AddDownloadsModal = () => {
|
|||||||
password: keychainPassword
|
password: keychainPassword
|
||||||
});
|
});
|
||||||
updatedItems[i] = {
|
updatedItems[i] = {
|
||||||
url,
|
url: meta.url || url,
|
||||||
file: lines.length === 1 && pendingAddFilename ? pendingAddFilename : meta.filename,
|
file: lines.length === 1 && pendingAddFilename ? pendingAddFilename : meta.filename,
|
||||||
size: meta.size,
|
size: meta.size,
|
||||||
sizeBytes: meta.size_bytes,
|
sizeBytes: meta.size_bytes,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { useDownloadStore } from '../store/useDownloadStore';
|
import { useDownloadStore } from '../store/useDownloadStore';
|
||||||
import { AlertTriangle } from 'lucide-react';
|
import { AlertTriangle } from 'lucide-react';
|
||||||
|
|
||||||
@@ -7,6 +7,13 @@ export const DeleteConfirmationModal: React.FC = () => {
|
|||||||
const [errorMessage, setErrorMessage] = useState('');
|
const [errorMessage, setErrorMessage] = useState('');
|
||||||
const [isRemoving, setIsRemoving] = useState(false);
|
const [isRemoving, setIsRemoving] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (deleteModalState.isOpen) {
|
||||||
|
setIsRemoving(false);
|
||||||
|
setErrorMessage('');
|
||||||
|
}
|
||||||
|
}, [deleteModalState.isOpen]);
|
||||||
|
|
||||||
if (!deleteModalState.isOpen) return null;
|
if (!deleteModalState.isOpen) return null;
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
@@ -38,6 +45,7 @@ export const DeleteConfirmationModal: React.FC = () => {
|
|||||||
setIsRemoving(false);
|
setIsRemoving(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setIsRemoving(false);
|
||||||
closeDeleteModal();
|
closeDeleteModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export const Sidebar: React.FC<SidebarProps> = (props) => {
|
|||||||
const getCount = (filter: SidebarFilter) => {
|
const getCount = (filter: SidebarFilter) => {
|
||||||
if (filter.startsWith('queue:')) {
|
if (filter.startsWith('queue:')) {
|
||||||
const qid = filter.replace('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) {
|
switch (filter) {
|
||||||
case 'all': return downloads.length;
|
case 'all': return downloads.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user