From 70825c9e571d90d9d4a84e10105e06e550f17f03 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 30 Nov 2022 16:32:47 +0000 Subject: [PATCH 1/5] fix(firestore, web): change `synchronizeTabs` to `forceOwnership` --- .../lib/src/persistence_settings.dart | 4 ++-- .../cloud_firestore_web/lib/cloud_firestore_web.dart | 2 +- .../lib/src/interop/firestore_interop.dart | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart index 4cb38b126776..476b1b4b8e20 100644 --- a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart +++ b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart @@ -11,10 +11,10 @@ class PersistenceSettings { /// shared execution of queries and latency-compensated local document updates across all connected instances. /// To enable this mode, synchronizeTabs:true needs to be set globally in all active tabs. /// If omitted or set to 'false', enablePersistence() will fail in all but the first tab. - final bool synchronizeTabs; + final bool forceOwnership; /// Creates a [PersistenceSettings] instance. const PersistenceSettings({ - required this.synchronizeTabs, + required this.forceOwnership, }); } diff --git a/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart b/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart index 28d6c9c64a27..0f6da7d7e43e 100644 --- a/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart +++ b/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart @@ -159,7 +159,7 @@ class FirebaseFirestoreWeb extends FirebaseFirestorePlatform { if (settings != null) { firestore_interop.PersistenceSettings interopSettings = firestore_interop.PersistenceSettings( - synchronizeTabs: settings.synchronizeTabs); + forceOwnership: settings.forceOwnership); return convertWebExceptions( () => _delegate.enablePersistence(interopSettings)); diff --git a/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart b/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart index 18c1f2b2e21d..78a1b8a4915c 100644 --- a/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart +++ b/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart @@ -265,8 +265,8 @@ class CollectionReferenceJsImpl extends QueryJsImpl { @anonymous @JS() class PersistenceSettings { - external bool get synchronizeTabs; - external factory PersistenceSettings({bool? synchronizeTabs}); + external bool get forceOwnership; + external factory PersistenceSettings({bool? forceOwnership}); } @JS() From bce390ead9d1da08f432e362d9ac43eb2bbe9a02 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 30 Nov 2022 16:47:46 +0000 Subject: [PATCH 2/5] bring back `synchronizeTabs` --- .../lib/src/persistence_settings.dart | 5 +++-- .../cloud_firestore_web/lib/cloud_firestore_web.dart | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart index 476b1b4b8e20..6b03bc252fd6 100644 --- a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart +++ b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart @@ -11,10 +11,11 @@ class PersistenceSettings { /// shared execution of queries and latency-compensated local document updates across all connected instances. /// To enable this mode, synchronizeTabs:true needs to be set globally in all active tabs. /// If omitted or set to 'false', enablePersistence() will fail in all but the first tab. - final bool forceOwnership; + final bool synchronizeTabs; /// Creates a [PersistenceSettings] instance. const PersistenceSettings({ - required this.forceOwnership, + @Deprecated('This property will be replaced by "forceOwnership" in a future release.') + required this.synchronizeTabs, }); } diff --git a/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart b/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart index 0f6da7d7e43e..2e45603552e4 100644 --- a/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart +++ b/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart @@ -159,7 +159,7 @@ class FirebaseFirestoreWeb extends FirebaseFirestorePlatform { if (settings != null) { firestore_interop.PersistenceSettings interopSettings = firestore_interop.PersistenceSettings( - forceOwnership: settings.forceOwnership); + forceOwnership: settings.synchronizeTabs); return convertWebExceptions( () => _delegate.enablePersistence(interopSettings)); From 0136a2af3693a6e6ea8b3b7a46dd75adbda97acd Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 30 Nov 2022 17:07:46 +0000 Subject: [PATCH 3/5] fix analyse issue --- .../lib/src/persistence_settings.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart index 6b03bc252fd6..5465d1eeb97c 100644 --- a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart +++ b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart @@ -11,6 +11,8 @@ class PersistenceSettings { /// shared execution of queries and latency-compensated local document updates across all connected instances. /// To enable this mode, synchronizeTabs:true needs to be set globally in all active tabs. /// If omitted or set to 'false', enablePersistence() will fail in all but the first tab. + @Deprecated( + 'This property will be replaced by "forceOwnership" in a future release.') final bool synchronizeTabs; /// Creates a [PersistenceSettings] instance. From 52ce8de0850e025b21e4f7e8fa18f6e58af5a243 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Thu, 1 Dec 2022 09:30:35 +0000 Subject: [PATCH 4/5] fix analyse issue --- .../cloud_firestore_web/lib/cloud_firestore_web.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart b/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart index 2e45603552e4..932b9eaebeb0 100644 --- a/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart +++ b/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart @@ -159,6 +159,7 @@ class FirebaseFirestoreWeb extends FirebaseFirestorePlatform { if (settings != null) { firestore_interop.PersistenceSettings interopSettings = firestore_interop.PersistenceSettings( + // ignore: deprecated_member_use forceOwnership: settings.synchronizeTabs); return convertWebExceptions( From c293a8a08ec77dafb34c67d13efb0b5c80135f56 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 7 Dec 2022 14:59:05 +0000 Subject: [PATCH 5/5] fix(firestore): use `enableMultiTabIndexedDbPersistence` to enable persistence --- .../lib/src/persistence_settings.dart | 5 +---- .../cloud_firestore_web/lib/cloud_firestore_web.dart | 3 +-- .../lib/src/interop/firestore.dart | 11 ++++++++--- .../lib/src/interop/firestore_interop.dart | 7 ++++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart index 5465d1eeb97c..4cb38b126776 100644 --- a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart +++ b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/persistence_settings.dart @@ -11,13 +11,10 @@ class PersistenceSettings { /// shared execution of queries and latency-compensated local document updates across all connected instances. /// To enable this mode, synchronizeTabs:true needs to be set globally in all active tabs. /// If omitted or set to 'false', enablePersistence() will fail in all but the first tab. - @Deprecated( - 'This property will be replaced by "forceOwnership" in a future release.') final bool synchronizeTabs; /// Creates a [PersistenceSettings] instance. const PersistenceSettings({ - @Deprecated('This property will be replaced by "forceOwnership" in a future release.') - required this.synchronizeTabs, + required this.synchronizeTabs, }); } diff --git a/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart b/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart index 932b9eaebeb0..28d6c9c64a27 100644 --- a/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart +++ b/packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart @@ -159,8 +159,7 @@ class FirebaseFirestoreWeb extends FirebaseFirestorePlatform { if (settings != null) { firestore_interop.PersistenceSettings interopSettings = firestore_interop.PersistenceSettings( - // ignore: deprecated_member_use - forceOwnership: settings.synchronizeTabs); + synchronizeTabs: settings.synchronizeTabs); return convertWebExceptions( () => _delegate.enablePersistence(interopSettings)); diff --git a/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore.dart b/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore.dart index 0d8f41908677..17ea8867c9aa 100644 --- a/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore.dart +++ b/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore.dart @@ -63,9 +63,14 @@ class Firestore extends JsObjectWrapper { firestore_interop.doc(jsObject, documentPath)); Future enablePersistence( - [firestore_interop.PersistenceSettings? settings]) => - handleThenable( - firestore_interop.enableIndexedDbPersistence(jsObject, settings)); + [firestore_interop.PersistenceSettings? settings]) { + if (settings != null && settings.synchronizeTabs == true) { + return handleThenable( + firestore_interop.enableMultiTabIndexedDbPersistence(jsObject)); + } + return handleThenable( + firestore_interop.enableIndexedDbPersistence(jsObject)); + } Stream snapshotsInSync() { late StreamController controller; diff --git a/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart b/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart index 78a1b8a4915c..8d5778553368 100644 --- a/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart +++ b/packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart @@ -85,7 +85,8 @@ external PromiseJsImpl enableIndexedDbPersistence( @JS() external PromiseJsImpl enableMultiTabIndexedDbPersistence( - FirestoreJsImpl firestore); + FirestoreJsImpl firestore, +); @JS() external PromiseJsImpl enableNetwork(FirestoreJsImpl firestore); @@ -265,8 +266,8 @@ class CollectionReferenceJsImpl extends QueryJsImpl { @anonymous @JS() class PersistenceSettings { - external bool get forceOwnership; - external factory PersistenceSettings({bool? forceOwnership}); + external bool get synchronizeTabs; + external factory PersistenceSettings({bool? synchronizeTabs}); } @JS()