refactor: make the geoip download toast the same as regular download toast

This commit is contained in:
zhom
2025-08-11 09:59:36 +04:00
parent 55b8955a20
commit 140621dcbe
2 changed files with 60 additions and 5 deletions
+19 -2
View File
@@ -319,6 +319,10 @@ export function useBrowserDownload() {
stage: string;
percentage: number;
message: string;
downloaded_bytes?: number;
total_bytes?: number;
speed_bytes_per_sec?: number;
eta_seconds?: number;
}>(
"geoip-download-progress",
(
@@ -326,16 +330,29 @@ export function useBrowserDownload() {
stage: string;
percentage: number;
message: string;
downloaded_bytes?: number;
total_bytes?: number;
speed_bytes_per_sec?: number;
eta_seconds?: number;
}>,
) => {
const { stage, percentage } = event.payload;
const { stage, percentage, speed_bytes_per_sec, eta_seconds } =
event.payload;
if (stage === "downloading") {
const speedMBps = speed_bytes_per_sec
? (speed_bytes_per_sec / (1024 * 1024)).toFixed(1)
: undefined;
const etaText = eta_seconds ? formatTime(eta_seconds) : undefined;
showToast({
id: "geoip-download",
type: "download",
title: "Downloading GeoIP database",
stage: "downloading",
progress: { percentage },
progress: {
percentage,
...(speedMBps ? { speed: speedMBps } : {}),
...(etaText ? { eta: etaText } : {}),
},
});
} else if (stage === "completed") {
showToast({