@@ -15,7 +15,7 @@ use crate::{
1515 interface:: { RequestedStreamSubscription , StreamSubscriptionRequest } ,
1616 streaming_sync:: { OwnedStreamDescription , RequestedStreamSubscriptions } ,
1717 subscriptions:: { LocallyTrackedSubscription , StreamKey } ,
18- sync_status:: SyncPriorityStatus ,
18+ sync_status:: { ActiveStreamSubscription , DownloadSyncStatus , SyncPriorityStatus } ,
1919 } ,
2020 sync_local:: { PartialSyncOperation , SyncOperation } ,
2121 util:: { JsonString , column_nullable} ,
@@ -87,30 +87,45 @@ impl StorageAdapter {
8787 Ok ( requests)
8888 }
8989
90- pub fn collect_sync_state ( & self ) -> Result < Vec < SyncPriorityStatus > , PowerSyncError > {
91- // language=SQLite
92- let statement = self
90+ pub fn offline_sync_state ( & self ) -> Result < DownloadSyncStatus , PowerSyncError > {
91+ let priority_items = {
92+ // language=SQLite
93+ let statement = self
9394 . db
9495 . prepare_v2 (
9596 "SELECT priority, unixepoch(last_synced_at) FROM ps_sync_state ORDER BY priority" ,
9697 )
9798 . into_db_result ( self . db ) ?;
9899
99- let mut items = Vec :: < SyncPriorityStatus > :: new ( ) ;
100- while statement. step ( ) ? == ResultCode :: ROW {
101- let priority = BucketPriority {
102- number : statement. column_int ( 0 ) ,
103- } ;
104- let timestamp = statement. column_int64 ( 1 ) ;
105-
106- items. push ( SyncPriorityStatus {
107- priority,
108- last_synced_at : Some ( Timestamp ( timestamp) ) ,
109- has_synced : Some ( true ) ,
110- } ) ;
111- }
100+ let mut items = Vec :: < SyncPriorityStatus > :: new ( ) ;
101+ while statement. step ( ) ? == ResultCode :: ROW {
102+ let priority = BucketPriority {
103+ number : statement. column_int ( 0 ) ,
104+ } ;
105+ let timestamp = statement. column_int64 ( 1 ) ;
112106
113- return Ok ( items) ;
107+ items. push ( SyncPriorityStatus {
108+ priority,
109+ last_synced_at : Some ( Timestamp ( timestamp) ) ,
110+ has_synced : Some ( true ) ,
111+ } ) ;
112+ }
113+
114+ items
115+ } ;
116+
117+ let mut streams = Vec :: new ( ) ;
118+ self . iterate_local_subscriptions ( |sub| {
119+ streams. push ( ActiveStreamSubscription :: from_local ( & sub) ) ;
120+ } ) ?;
121+
122+ Ok ( DownloadSyncStatus {
123+ connected : false ,
124+ connecting : false ,
125+ priority_status : priority_items,
126+ downloading : None ,
127+ streams,
128+ } )
114129 }
115130
116131 pub fn delete_buckets < ' a > (
0 commit comments