File tree Expand file tree Collapse file tree 2 files changed +8
-20
lines changed
packages/powersync/lib/src Expand file tree Collapse file tree 2 files changed +8
-20
lines changed Original file line number Diff line number Diff line change @@ -42,11 +42,7 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
4242 final SqliteDatabase database;
4343
4444 /// Current connection status.
45- SyncStatus currentStatus = const SyncStatus (
46- connected: false ,
47- uploading: false ,
48- downloading: false ,
49- lastSyncedAt: null );
45+ SyncStatus currentStatus = const SyncStatus ();
5046
5147 /// Use this stream to subscribe to connection status updates.
5248 late final Stream <SyncStatus > statusStream;
@@ -203,11 +199,8 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
203199 final SyncStatus status = data[1 ];
204200 _setStatus (status);
205201 } else if (action == 'close' ) {
206- _setStatus (SyncStatus (
207- connected: false ,
208- downloading: false ,
209- uploading: false ,
210- lastSyncedAt: currentStatus.lastSyncedAt));
202+ // Clear status apart from lastSyncedAt
203+ _setStatus (SyncStatus (lastSyncedAt: currentStatus.lastSyncedAt));
211204 rPort.close ();
212205 updateSubscription? .cancel ();
213206 } else if (action == 'log' ) {
@@ -238,11 +231,8 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
238231 _disconnecter? .completeAbort ();
239232 _disconnecter = null ;
240233 rPort.close ();
241- _setStatus (SyncStatus (
242- connected: false ,
243- lastSyncedAt: currentStatus.lastSyncedAt,
244- downloading: false ,
245- uploading: false ));
234+ // Clear status apart from lastSyncedAt
235+ _setStatus (SyncStatus (lastSyncedAt: currentStatus.lastSyncedAt));
246236 }
247237
248238 var exitPort = ReceivePort ();
Original file line number Diff line number Diff line change @@ -35,11 +35,7 @@ class StreamingSyncImplementation {
3535
3636 final Duration retryDelay;
3737
38- SyncStatus lastStatus = SyncStatus (
39- connected: false ,
40- lastSyncedAt: null ,
41- downloading: false ,
42- uploading: false );
38+ SyncStatus lastStatus = const SyncStatus ();
4339
4440 StreamingSyncImplementation (
4541 {required this .adapter,
@@ -150,6 +146,8 @@ class StreamingSyncImplementation {
150146 return body['data' ]['write_checkpoint' ] as String ;
151147 }
152148
149+ /// Update sync status based on any non-null parameters.
150+ /// To clear errors, use [_noError] instead of null.
153151 void _updateStatus (
154152 {DateTime ? lastSyncedAt,
155153 bool ? connected,
You can’t perform that action at this time.
0 commit comments