@@ -7,36 +7,35 @@ import { FC, ReactNode } from 'react';
77 * a progress indicator otherwise.
88 */
99export const GuardBySync : FC < { children : ReactNode ; priority ?: number } > = ( { children, priority } ) => {
10- const status = useStatus ( ) ;
11-
12- const hasSynced = priority == null ? status . hasSynced : status . statusForPriority ( priority ) . hasSynced ;
13- if ( hasSynced ) {
14- return children ;
15- }
16-
17- // If we haven't completed a sync yet, show a progress indicator!
18- const allProgress = status . downloadProgress ;
19- const progress = priority == null ? allProgress : allProgress ?. untilPriority ( priority ) ;
20-
21- return (
22- < Stack direction = "column" spacing = { 1 } sx = { { p : 4 } } alignItems = "stretch" >
23- { progress != null ? (
24- < >
25- < LinearProgress variant = "determinate" value = { progress . downloadedFraction * 100 } />
26- < Box sx = { { alignSelf : "center" } } >
27- { progress . downloadedOperations == progress . totalOperations ? (
28- < Typography > Applying server-side changes</ Typography >
29- ) : (
30- < Typography >
31- Downloaded { progress . downloadedOperations } out of { progress . totalOperations } .
32- </ Typography >
33- ) }
34- </ Box >
35- </ >
36- ) : (
37- < LinearProgress variant = "indeterminate" />
38- ) }
39- </ Stack >
40- ) ;
41- } ;
42-
10+ const status = useStatus ( ) ;
11+
12+ const hasSynced = priority == null ? status . hasSynced : status . statusForPriority ( priority ) . hasSynced ;
13+ if ( hasSynced ) {
14+ return children ;
15+ }
16+
17+ // If we haven't completed a sync yet, show a progress indicator!
18+ const allProgress = status . downloadProgress ;
19+ const progress = priority == null ? allProgress : allProgress ?. untilPriority ( priority ) ;
20+
21+ return (
22+ < Stack direction = "column" spacing = { 1 } sx = { { p : 4 } } alignItems = "stretch" >
23+ { progress != null ? (
24+ < >
25+ < LinearProgress variant = "determinate" value = { progress . downloadedFraction * 100 } />
26+ < Box sx = { { alignSelf : 'center' } } >
27+ { progress . downloadedOperations == progress . totalOperations ? (
28+ < Typography > Applying server-side changes</ Typography >
29+ ) : (
30+ < Typography >
31+ Downloaded { progress . downloadedOperations } out of { progress . totalOperations } .
32+ </ Typography >
33+ ) }
34+ </ Box >
35+ </ >
36+ ) : (
37+ < LinearProgress variant = "indeterminate" />
38+ ) }
39+ </ Stack >
40+ ) ;
41+ } ;
0 commit comments