File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ SELECT cloudsync_network_set_apikey('your-api-key-here');
168168
169169-- Pull data from Device A - repeat until data is received
170170SELECT cloudsync_network_sync();
171- -- Keep calling until the function returns > 0 (indicating data was received)
171+ -- Check the "rowsReceived" field in the JSON result to see if data was received
172172SELECT cloudsync_network_sync();
173173
174174-- Verify data was synced
@@ -199,7 +199,7 @@ SELECT cloudsync_network_sync();
199199``` sql
200200-- Get updates from Device B - repeat until data is received
201201SELECT cloudsync_network_sync();
202- -- Keep calling until the function returns > 0 (indicating data was received)
202+ -- Check the "rowsReceived" field in the JSON result to see if data was received
203203SELECT cloudsync_network_sync();
204204
205205-- View all tasks (should now include Device B's additions)
@@ -232,7 +232,7 @@ SELECT cloudsync_network_has_unsent_changes();
232232-- When network returns, sync automatically resolves conflicts
233233-- Repeat until all changes are synchronized
234234SELECT cloudsync_network_sync();
235- -- Keep calling until the function returns > 0 (indicating data was received/sent)
235+ -- Check the "rowsReceived" field in the JSON result to see if data was received/sent
236236SELECT cloudsync_network_sync();
237237```
238238
Original file line number Diff line number Diff line change @@ -58,10 +58,14 @@ export const SyncProvider = ({ children }) => {
5858
5959 const result = await Promise . race ( [ queryPromise , timeoutPromise ] ) ;
6060
61- if ( result . rows && result . rows . length > 0 && result . rows [ 0 ] [ 'cloudsync_network_check_changes()' ] > 0 ) {
62- console . log ( `${ result . rows [ 0 ] [ 'cloudsync_network_check_changes()' ] } changes detected, triggering refresh` ) ;
63- // Defer refresh to next tick to avoid blocking current interaction
64- setTimeout ( ( ) => triggerRefresh ( ) , 0 ) ;
61+ const raw = result . rows ?. [ 0 ] ?. [ 'cloudsync_network_check_changes()' ] ;
62+ if ( raw ) {
63+ const { rowsReceived } = JSON . parse ( raw ) ;
64+ if ( rowsReceived > 0 ) {
65+ console . log ( `${ rowsReceived } changes detected, triggering refresh` ) ;
66+ // Defer refresh to next tick to avoid blocking current interaction
67+ setTimeout ( ( ) => triggerRefresh ( ) , 0 ) ;
68+ }
6569 }
6670 } catch ( error ) {
6771 console . error ( 'Error checking for changes:' , error ) ;
You can’t perform that action at this time.
0 commit comments