@@ -7,16 +7,16 @@ import prompt from 'react-native-prompt-android';
77import { router , Stack } from 'expo-router' ;
88import { LIST_TABLE , TODO_TABLE , ListRecord } from '../../../library/powersync/AppSchema' ;
99import { useSystem } from '../../../library/powersync/system' ;
10- import { useQuery , useStatus } from '@powersync/react-native' ;
10+ import { useQuery } from '@powersync/react-native' ;
1111import { ListItemWidget } from '../../../library/widgets/ListItemWidget' ;
12+ import { GuardBySync } from '../../../library/widgets/GuardBySync' ;
1213
1314const description = ( total : number , completed : number = 0 ) => {
1415 return `${ total - completed } pending, ${ completed } completed` ;
1516} ;
1617
1718const ListsViewWidget : React . FC = ( ) => {
1819 const system = useSystem ( ) ;
19- const status = useStatus ( ) ;
2020 const { data : listRecords } = useQuery < ListRecord & { total_tasks : number ; completed_tasks : number } > ( `
2121 SELECT
2222 ${ 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 = () => {
7878 ) ;
7979 } }
8080 />
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 >
101101
102102 < StatusBar style = { 'light' } />
103103 </ View >
0 commit comments