@@ -13,7 +13,7 @@ import 'package:powersync_core/src/powersync_update_notification.dart';
13
13
import 'package:powersync_core/src/schema.dart' ;
14
14
import 'package:powersync_core/src/schema_logic.dart' ;
15
15
import 'package:powersync_core/src/schema_logic.dart' as schema_logic;
16
- import 'package:powersync_core/src/sync_status.dart' ;
16
+ import 'package:powersync_core/src/sync/ sync_status.dart' ;
17
17
18
18
mixin PowerSyncDatabaseMixin implements SqliteConnection {
19
19
/// Schema used for the local database.
@@ -208,16 +208,27 @@ mixin PowerSyncDatabaseMixin implements SqliteConnection {
208
208
@visibleForTesting
209
209
void setStatus (SyncStatus status) {
210
210
if (status != currentStatus) {
211
- // Note that currently the streaming sync implementation will never set hasSynced.
212
- // lastSyncedAt implies that syncing has completed at some point (hasSynced = true).
213
- // The previous values of hasSynced should be preserved here.
214
- final newStatus = status.copyWith (
215
- hasSynced: status.lastSyncedAt != null
216
- ? true
217
- : status.hasSynced ?? currentStatus.hasSynced,
218
- lastSyncedAt: status.lastSyncedAt ?? currentStatus.lastSyncedAt);
219
- // If the absence of hasSync was the only difference, the new states would be equal
220
- // and don't require an event. So, check again.
211
+ final newStatus = SyncStatus (
212
+ connected: status.connected,
213
+ downloading: status.downloading,
214
+ uploading: status.uploading,
215
+ connecting: status.connecting,
216
+ uploadError: status.uploadError,
217
+ downloadError: status.downloadError,
218
+ priorityStatusEntries: status.priorityStatusEntries,
219
+ downloadProgress: status.downloadProgress,
220
+ // Note that currently the streaming sync implementation will never set
221
+ // hasSynced. lastSyncedAt implies that syncing has completed at some
222
+ // point (hasSynced = true).
223
+ // The previous values of hasSynced should be preserved here.
224
+ lastSyncedAt: status.lastSyncedAt ?? currentStatus.lastSyncedAt,
225
+ hasSynced: status.lastSyncedAt != null
226
+ ? true
227
+ : status.hasSynced ?? currentStatus.hasSynced,
228
+ );
229
+
230
+ // If the absence of hasSynced was the only difference, the new states
231
+ // would be equal and don't require an event. So, check again.
221
232
if (newStatus != currentStatus) {
222
233
currentStatus = newStatus;
223
234
statusStreamController.add (currentStatus);
0 commit comments