@@ -7,16 +7,16 @@ import prompt from 'react-native-prompt-android';
7
7
import { router , Stack } from 'expo-router' ;
8
8
import { LIST_TABLE , TODO_TABLE , ListRecord } from '../../../library/powersync/AppSchema' ;
9
9
import { useSystem } from '../../../library/powersync/system' ;
10
- import { useQuery , useStatus } from '@powersync/react-native' ;
10
+ import { useQuery } from '@powersync/react-native' ;
11
11
import { ListItemWidget } from '../../../library/widgets/ListItemWidget' ;
12
+ import { GuardBySync } from '../../../library/widgets/GuardBySync' ;
12
13
13
14
const description = ( total : number , completed : number = 0 ) => {
14
15
return `${ total - completed } pending, ${ completed } completed` ;
15
16
} ;
16
17
17
18
const ListsViewWidget : React . FC = ( ) => {
18
19
const system = useSystem ( ) ;
19
- const status = useStatus ( ) ;
20
20
const { data : listRecords } = useQuery < ListRecord & { total_tasks : number ; completed_tasks : number } > ( `
21
21
SELECT
22
22
${ LIST_TABLE } .*, COUNT(${ TODO_TABLE } .id) AS total_tasks, SUM(CASE WHEN ${ TODO_TABLE } .completed = true THEN 1 ELSE 0 END) as completed_tasks
@@ -78,26 +78,26 @@ const ListsViewWidget: React.FC = () => {
78
78
) ;
79
79
} }
80
80
/>
81
- < ScrollView key = { 'lists' } style = { { maxHeight : '90%' } } >
82
- { ! status . hasSynced ? (
83
- < Text > Busy with sync... </ Text >
84
- ) : (
85
- listRecords . map ( ( r ) => (
86
- < ListItemWidget
87
- key = { r . id }
88
- title = { r . name }
89
- description = { description ( r . total_tasks , r . completed_tasks ) }
90
- onDelete = { ( ) => deleteList ( r . id ) }
91
- onPress = { ( ) => {
92
- router . push ( {
93
- pathname : 'views/todos/edit/[id]' ,
94
- params : { id : r . id }
95
- } ) ;
96
- } }
97
- />
98
- ) )
99
- ) }
100
- </ ScrollView >
81
+ < GuardBySync >
82
+ < ScrollView key = { 'lists' } style = { { maxHeight : '90%' } } >
83
+ { (
84
+ listRecords . map ( ( r ) => (
85
+ < ListItemWidget
86
+ key = { r . id }
87
+ title = { r . name ! }
88
+ description = { description ( r . total_tasks , r . completed_tasks ) }
89
+ onDelete = { ( ) => deleteList ( r . id ) }
90
+ onPress = { ( ) => {
91
+ router . push ( {
92
+ pathname : 'views/todos/edit/[id]' ,
93
+ params : { id : r . id }
94
+ } ) ;
95
+ } }
96
+ />
97
+ ) )
98
+ ) }
99
+ </ ScrollView >
100
+ </ GuardBySync >
101
101
102
102
< StatusBar style = { 'light' } />
103
103
</ View >
0 commit comments