diff --git a/CHANGELOG.md b/CHANGELOG.md index b6b62926..cd539f70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,32 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2025-01-16 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`powersync` - `v1.11.1`](#powersync---v1111) + - [`powersync_sqlcipher` - `v0.1.3`](#powersync_sqlcipher---v013) + +--- + +#### `powersync` - `v1.11.1` + + - Fix `statusStream` emitting the same sync status multiple times. + +#### `powersync_sqlcipher` - `v0.1.3` + + - Fix `statusStream` emitting the same sync status multiple times. + + ## 2025-01-06 ### Changes diff --git a/demos/benchmarks/pubspec.yaml b/demos/benchmarks/pubspec.yaml index 0060e620..8af7e01e 100644 --- a/demos/benchmarks/pubspec.yaml +++ b/demos/benchmarks/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - powersync: ^1.11.0 + powersync: ^1.11.1 path_provider: ^2.1.1 path: ^1.8.3 logging: ^1.2.0 diff --git a/demos/django-todolist/pubspec.yaml b/demos/django-todolist/pubspec.yaml index e98d7801..7c44e523 100644 --- a/demos/django-todolist/pubspec.yaml +++ b/demos/django-todolist/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - powersync: ^1.11.0 + powersync: ^1.11.1 path_provider: ^2.1.1 path: ^1.8.3 logging: ^1.2.0 diff --git a/demos/firebase-nodejs-todolist/pubspec.yaml b/demos/firebase-nodejs-todolist/pubspec.yaml index e399e4a9..4e0efe45 100644 --- a/demos/firebase-nodejs-todolist/pubspec.yaml +++ b/demos/firebase-nodejs-todolist/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.11.0 + powersync: ^1.11.1 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/demos/supabase-anonymous-auth/pubspec.yaml b/demos/supabase-anonymous-auth/pubspec.yaml index 26456ed3..b8da34bd 100644 --- a/demos/supabase-anonymous-auth/pubspec.yaml +++ b/demos/supabase-anonymous-auth/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.11.0 + powersync: ^1.11.1 path_provider: ^2.1.1 supabase_flutter: ^2.0.2 path: ^1.8.3 diff --git a/demos/supabase-edge-function-auth/pubspec.yaml b/demos/supabase-edge-function-auth/pubspec.yaml index 5c842962..109220f0 100644 --- a/demos/supabase-edge-function-auth/pubspec.yaml +++ b/demos/supabase-edge-function-auth/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.11.0 + powersync: ^1.11.1 path_provider: ^2.1.1 supabase_flutter: ^2.0.2 path: ^1.8.3 diff --git a/demos/supabase-simple-chat/pubspec.yaml b/demos/supabase-simple-chat/pubspec.yaml index 46007760..42ed12aa 100644 --- a/demos/supabase-simple-chat/pubspec.yaml +++ b/demos/supabase-simple-chat/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: supabase_flutter: ^2.0.2 timeago: ^3.6.0 - powersync: ^1.11.0 + powersync: ^1.11.1 path_provider: ^2.1.1 path: ^1.8.3 logging: ^1.2.0 diff --git a/demos/supabase-todolist-drift/pubspec.yaml b/demos/supabase-todolist-drift/pubspec.yaml index e14678ce..53898117 100644 --- a/demos/supabase-todolist-drift/pubspec.yaml +++ b/demos/supabase-todolist-drift/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: flutter: sdk: flutter powersync_attachments_helper: ^0.6.17 - powersync: ^1.11.0 + powersync: ^1.11.1 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/demos/supabase-todolist-optional-sync/pubspec.yaml b/demos/supabase-todolist-optional-sync/pubspec.yaml index 9820ce34..579d66e0 100644 --- a/demos/supabase-todolist-optional-sync/pubspec.yaml +++ b/demos/supabase-todolist-optional-sync/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - powersync: ^1.11.0 + powersync: ^1.11.1 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/demos/supabase-todolist/pubspec.yaml b/demos/supabase-todolist/pubspec.yaml index aaed890c..fb668184 100644 --- a/demos/supabase-todolist/pubspec.yaml +++ b/demos/supabase-todolist/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter powersync_attachments_helper: ^0.6.17 - powersync: ^1.11.0 + powersync: ^1.11.1 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/packages/powersync/CHANGELOG.md b/packages/powersync/CHANGELOG.md index f16b9ee7..b7b7294b 100644 --- a/packages/powersync/CHANGELOG.md +++ b/packages/powersync/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.11.1 + + - Fix `statusStream` emitting the same sync status multiple times. + ## 1.11.0 - Increase limit on number of columns per table to 1999. diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index 192cf36b..7b13b4bd 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -1,5 +1,5 @@ name: powersync -version: 1.11.0 +version: 1.11.1 homepage: https://powersync.com repository: https://github.com/powersync-ja/powersync.dart description: PowerSync Flutter SDK - sync engine for building local-first apps. @@ -11,7 +11,7 @@ dependencies: sdk: flutter sqlite3_flutter_libs: ^0.5.23 - powersync_core: ^1.1.0 + powersync_core: ^1.1.1 powersync_flutter_libs: ^0.4.4 collection: ^1.17.0 pubspec_parse: ^1.3.0 diff --git a/packages/powersync_core/CHANGELOG.md b/packages/powersync_core/CHANGELOG.md index c70b5525..3fcf080f 100644 --- a/packages/powersync_core/CHANGELOG.md +++ b/packages/powersync_core/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.1 + +- Fix `statusStream` emitting the same sync status multiple times. + ## 1.1.0 - Increase limit on number of columns per table to 1999. diff --git a/packages/powersync_core/lib/src/database/powersync_db_mixin.dart b/packages/powersync_core/lib/src/database/powersync_db_mixin.dart index bc359616..a5fb93a5 100644 --- a/packages/powersync_core/lib/src/database/powersync_db_mixin.dart +++ b/packages/powersync_core/lib/src/database/powersync_db_mixin.dart @@ -148,17 +148,23 @@ mixin PowerSyncDatabaseMixin implements SqliteConnection { } @protected + @visibleForTesting void setStatus(SyncStatus status) { if (status != currentStatus) { - currentStatus = status.copyWith( - // Note that currently the streaming sync implementation will never set hasSynced. - // lastSyncedAt implies that syncing has completed at some point (hasSynced = true). - // The previous values of hasSynced should be preserved here. + // Note that currently the streaming sync implementation will never set hasSynced. + // lastSyncedAt implies that syncing has completed at some point (hasSynced = true). + // The previous values of hasSynced should be preserved here. + final newStatus = status.copyWith( hasSynced: status.lastSyncedAt != null ? true : status.hasSynced ?? currentStatus.hasSynced, lastSyncedAt: status.lastSyncedAt ?? currentStatus.lastSyncedAt); - statusStreamController.add(currentStatus); + // If the absence of hasSync was the only difference, the new states would be equal + // and don't require an event. So, check again. + if (newStatus != currentStatus) { + currentStatus = newStatus; + statusStreamController.add(currentStatus); + } } } @@ -181,6 +187,7 @@ mixin PowerSyncDatabaseMixin implements SqliteConnection { await disconnect(); // Now we can close the database await database.close(); + await statusStreamController.close(); } /// Connect to the PowerSync service, and keep the databases in sync. diff --git a/packages/powersync_core/lib/src/version.dart b/packages/powersync_core/lib/src/version.dart index 99e35a29..5333794a 100644 --- a/packages/powersync_core/lib/src/version.dart +++ b/packages/powersync_core/lib/src/version.dart @@ -1 +1 @@ -const String libraryVersion = '1.1.0'; +const String libraryVersion = '1.1.1'; diff --git a/packages/powersync_core/pubspec.yaml b/packages/powersync_core/pubspec.yaml index cf972f47..336e6e0e 100644 --- a/packages/powersync_core/pubspec.yaml +++ b/packages/powersync_core/pubspec.yaml @@ -1,5 +1,5 @@ name: powersync_core -version: 1.1.0 +version: 1.1.1 homepage: https://powersync.com repository: https://github.com/powersync-ja/powersync.dart description: PowerSync Dart SDK - sync engine for building local-first apps. diff --git a/packages/powersync_core/test/powersync_shared_test.dart b/packages/powersync_core/test/powersync_shared_test.dart index 26b458d8..34405eb6 100644 --- a/packages/powersync_core/test/powersync_shared_test.dart +++ b/packages/powersync_core/test/powersync_shared_test.dart @@ -1,3 +1,4 @@ +import 'package:powersync_core/powersync_core.dart'; import 'package:sqlite_async/mutex.dart'; import 'package:test/test.dart'; import 'package:uuid/parsing.dart'; @@ -89,5 +90,27 @@ void main() { // Check that it is a valid uuid UuidParsing.parseAsByteList(id); }); + + test('does not emit duplicate sync status events', () async { + final db = await testUtils.setupPowerSync(path: path); + expectLater( + db.statusStream, + emitsInOrder( + [ + // Manual setStatus call. hasSynced set to true because lastSyncedAt is set + isA().having((e) => e.hasSynced, 'hasSynced', true), + // Closing the database emits a disconnected status + isA().having((e) => e.connected, 'connected', false), + emitsDone + ], + ), + ); + + final status = SyncStatus(connected: true, lastSyncedAt: DateTime.now()); + db.setStatus(status); + db.setStatus(status); // Should not re-emit! + + await db.close(); + }); }); } diff --git a/packages/powersync_sqlcipher/CHANGELOG.md b/packages/powersync_sqlcipher/CHANGELOG.md index 80b16f3c..1d6b5a5b 100644 --- a/packages/powersync_sqlcipher/CHANGELOG.md +++ b/packages/powersync_sqlcipher/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.3 + + - Fix `statusStream` emitting the same sync status multiple times. + ## 0.1.2 - Increase limit on number of columns per table to 1999. diff --git a/packages/powersync_sqlcipher/pubspec.yaml b/packages/powersync_sqlcipher/pubspec.yaml index af9fa4dd..f2ca9e03 100644 --- a/packages/powersync_sqlcipher/pubspec.yaml +++ b/packages/powersync_sqlcipher/pubspec.yaml @@ -1,5 +1,5 @@ name: powersync_sqlcipher -version: 0.1.2 +version: 0.1.3 homepage: https://powersync.com repository: https://github.com/powersync-ja/powersync.dart description: PowerSync Flutter SDK - sync engine for building local-first apps. @@ -12,7 +12,7 @@ dependencies: flutter: sdk: flutter - powersync_core: ^1.1.0 + powersync_core: ^1.1.1 powersync_flutter_libs: ^0.4.4 sqlcipher_flutter_libs: ^0.6.4 dev_dependencies: