mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-09 20:12:14 +10:00
* feat: small refactor * fix: appimage build script * fix: add NO_STRIP to AppImage build * fix: build and dev mode from refactor * fix: submodule step 1 * fix: submodules step 2
35 lines
837 B
TypeScript
35 lines
837 B
TypeScript
import { listen } from "@tauri-apps/api/event";
|
|
import type { DownloadableMetadata } from "~/types";
|
|
|
|
export type QueueState = {
|
|
queue: Array<{
|
|
meta: DownloadableMetadata;
|
|
status: string;
|
|
progress: number | null;
|
|
current: number;
|
|
max: number;
|
|
}>;
|
|
status: string;
|
|
};
|
|
|
|
export type StatsState = {
|
|
speed: number; // Bytes per second
|
|
time: number; // Seconds,
|
|
};
|
|
|
|
export const useQueueState = () =>
|
|
useState<QueueState>("queue", () => ({ queue: [], status: "Unknown" }));
|
|
|
|
export const useStatsState = () =>
|
|
useState<StatsState>("stats", () => ({ speed: 0, time: 0 }));
|
|
|
|
listen("update_queue", (event) => {
|
|
const queue = useQueueState();
|
|
queue.value = event.payload as QueueState;
|
|
});
|
|
|
|
listen("update_stats", (event) => {
|
|
const stats = useStatsState();
|
|
stats.value = event.payload as StatsState;
|
|
});
|