@@ -15,7 +15,7 @@ use crate::{
15
15
interface:: { RequestedStreamSubscription , StreamSubscriptionRequest } ,
16
16
streaming_sync:: { OwnedStreamDescription , RequestedStreamSubscriptions } ,
17
17
subscriptions:: { LocallyTrackedSubscription , StreamKey } ,
18
- sync_status:: SyncPriorityStatus ,
18
+ sync_status:: { ActiveStreamSubscription , DownloadSyncStatus , SyncPriorityStatus } ,
19
19
} ,
20
20
sync_local:: { PartialSyncOperation , SyncOperation } ,
21
21
util:: { JsonString , column_nullable} ,
@@ -87,30 +87,45 @@ impl StorageAdapter {
87
87
Ok ( requests)
88
88
}
89
89
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
93
94
. db
94
95
. prepare_v2 (
95
96
"SELECT priority, unixepoch(last_synced_at) FROM ps_sync_state ORDER BY priority" ,
96
97
)
97
98
. into_db_result ( self . db ) ?;
98
99
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 ) ;
112
106
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
+ } )
114
129
}
115
130
116
131
pub fn delete_buckets < ' a > (
0 commit comments