diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index a4e88db..1244d44 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -303,7 +303,6 @@ async fn download( status: Some(ProgressBarStatus::None), progress: Some(0), }); - let _ = app.emit("download-cancelled", format!("{}", name)); return "0".to_string(); } diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 7aa3d5f..a7f0ff1 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -297,27 +297,6 @@ export default function RootLayout ({ }) }) ) - - unlisteners.push( - await listen('download-cancelled', event => { - const displayName = event.payload - setDownloadProgress(prev => { - const i = prev.findIndex(d => d.version === displayName) - if (i === -1) return prev - if (prev[i].canceled) { - return prev.filter((_, idx) => idx !== i) - } - const copy = [...prev] - copy[i] = { - ...copy[i], - downloading: false, - paused: true, - failed: false - } - return copy - }) - }) - ) } setupListeners() @@ -518,7 +497,23 @@ export default function RootLayout ({ writeVersionsConfig(updated) return updated }) - } else if (res !== '0') { + } else if (res == '0') { + setDownloadProgress(prev => { + const i = prev.findIndex(d => d.version === info.id) + if (i === -1) return prev + if (prev[i].canceled) { + return prev.filter((_, idx) => idx !== i) + } + const copy = [...prev] + copy[i] = { + ...copy[i], + downloading: false, + paused: true, + failed: false + } + return copy + }) + } else if (res == '-1') { setDownloadProgress(prev => prev.map(d => d.version === versionId diff --git a/src/componets/popups/Downloads.tsx b/src/componets/popups/Downloads.tsx index b1e09c7..f201139 100644 --- a/src/componets/popups/Downloads.tsx +++ b/src/componets/popups/Downloads.tsx @@ -5,6 +5,9 @@ import { formatEtaSmart } from '@/lib/Util' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faCancel, faPause, faPlay } from '@fortawesome/free-solid-svg-icons' import { invoke } from '@tauri-apps/api/core' +import { writeVersionsConfig } from '@/lib/BazookaManager' +import { notifyUser } from '@/lib/Notifications' +import { getCurrentWindow, UserAttentionType } from '@tauri-apps/api/window' export default function DownloadsPopup () { const { @@ -12,7 +15,9 @@ export default function DownloadsPopup () { getVersionInfo, setDownloadProgress, downloadQueue, - setDownloadQueue + setDownloadQueue, + normalConfig, + setDownloadedVersionsConfig } = useGlobal() return ( @@ -29,26 +34,94 @@ export default function DownloadsPopup () {
-