Skip to content

Commit 2dcbb6b

Browse files
committed
Update cancelAnalysis to accept path param and improve job cancel logic
1 parent 2a1f306 commit 2dcbb6b

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/JobIndicator.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function JobIndicator() {
4545
];
4646

4747
const handleCancelJob = async (job: DisplayJob) => {
48-
await cancelAnalysis();
48+
await cancelAnalysis(job.path);
4949
};
5050

5151
const handleCancelAll = async () => {
@@ -79,7 +79,7 @@ export function JobIndicator() {
7979
<Button
8080
variant="ghost"
8181
size="sm"
82-
className="h-6 px-2 text-xs text-destructive hover:text-destructive"
82+
className="h-6 px-2 text-destructive text-xs hover:text-destructive"
8383
onClick={handleCancelAll}
8484
>
8585
Cancel All

src/stores/bitrateStore.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ interface BitrateState {
6767
analyzeStream: (path: string, streamIndex: number) => Promise<void>;
6868
analyzeOverall: (path: string, fileHash?: string) => Promise<void>;
6969
forceAnalyze: (path: string) => Promise<void>;
70-
cancelAnalysis: () => Promise<void>;
70+
cancelAnalysis: (path?: string) => Promise<void>;
7171
cancelAllJobs: () => Promise<void>;
7272
setAnalysisMode: (mode: "overall" | "per-stream") => void;
7373
setSelectedStreamIndex: (index: number | null) => void;
@@ -260,21 +260,26 @@ export const useBitrateStore = create<BitrateState>((set, get) => ({
260260
}
261261
},
262262

263-
cancelAnalysis: async () => {
263+
cancelAnalysis: async (path?: string) => {
264264
const { currentJobPath } = get();
265-
if (!currentJobPath) {
265+
const targetPath = path || currentJobPath;
266+
267+
if (!targetPath) {
266268
console.log("[BitrateStore] No analysis to cancel");
267269
return;
268270
}
269271

270-
console.log(`[BitrateStore] Cancelling analysis for: ${currentJobPath}`);
272+
console.log(`[BitrateStore] Cancelling analysis for: ${targetPath}`);
271273
try {
272274
const cancelled = await invoke<boolean>("cancel_bitrate_analysis", {
273-
path: currentJobPath,
275+
path: targetPath,
274276
});
275277
if (cancelled) {
276278
console.log("[BitrateStore] Analysis cancelled successfully");
277-
set({ loading: false, currentJobPath: null });
279+
// Only clear currentJobPath if we cancelled the current job
280+
if (targetPath === currentJobPath) {
281+
set({ loading: false, currentJobPath: null });
282+
}
278283
} else {
279284
console.log("[BitrateStore] No active job found to cancel");
280285
}

0 commit comments

Comments
 (0)