@@ -17,6 +17,7 @@ import { type TreeNode, TreeState } from "$lib/components/tree/index.svelte";
1717import { VList } from "virtua/svelte" ;
1818import { Context , Debounced } from "runed" ;
1919import { MediaQuery } from "svelte/reactivity" ;
20+ import { ProgressBarState } from "$lib/components/progress-bar/index.svelte" ;
2021
2122export type SidebarLocation = "left" | "right" ;
2223
@@ -327,6 +328,7 @@ export class MultiFileDiffViewerState {
327328 activeSearchResult : ActiveSearchResult | null = $state ( null ) ;
328329 sidebarCollapsed = $state ( false ) ;
329330 diffMetadata : DiffMetadata | null = $state ( null ) ;
331+ readonly progressBar = $state ( new ProgressBarState ( 100 , 100 ) ) ;
330332
331333 readonly fileTreeFilterDebounced = new Debounced ( ( ) => this . fileTreeFilter , 500 ) ;
332334 readonly searchQueryDebounced = new Debounced ( ( ) => this . searchQuery , 500 ) ;
@@ -457,15 +459,20 @@ export class MultiFileDiffViewerState {
457459 // Reset state
458460 this . collapsed = [ ] ;
459461 this . checked = [ ] ;
462+ this . diffMetadata = null ;
460463 this . fileDetails = [ ] ;
461464 this . clearImages ( ) ;
462465 this . vlist ?. scrollToIndex ( 0 , { align : "start" } ) ;
463- this . diffMetadata = meta ;
464466
467+ // Load new state
468+ this . diffMetadata = meta ;
465469 patches . sort ( compareFileDetails ) ;
466-
467- // Set this last since it's what the VList loads
468470 this . fileDetails . push ( ...patches ) ;
471+
472+ // in case the caller didn't close the progress
473+ if ( ! this . progressBar . isDone ( ) ) {
474+ this . progressBar . setProgress ( 100 , 100 ) ;
475+ }
469476 }
470477
471478 // TODO fails for initial commit?
@@ -476,10 +483,12 @@ export class MultiFileDiffViewerState {
476483
477484 try {
478485 if ( type === "commit" ) {
486+ this . progressBar . setSpinning ( ) ;
479487 const { info, files } = await fetchGithubCommitDiff ( token , owner , repo , id . split ( "/" ) [ 0 ] ) ;
480488 this . loadPatches ( files , { type : "github" , details : info } ) ;
481489 return true ;
482490 } else if ( type === "pull" ) {
491+ this . progressBar . setSpinning ( ) ;
483492 const { info, files } = await fetchGithubPRComparison ( token , owner , repo , id . split ( "/" ) [ 0 ] ) ;
484493 this . loadPatches ( files , { type : "github" , details : info } ) ;
485494 return true ;
@@ -492,6 +501,7 @@ export class MultiFileDiffViewerState {
492501 return false ;
493502 }
494503 }
504+ this . progressBar . setSpinning ( ) ;
495505 const base = refs [ 0 ] ;
496506 const head = refs [ 1 ] ;
497507 const { info, files } = await fetchGithubComparison ( token , owner , repo , base , head ) ;
0 commit comments