Skip to content

Commit 1466627

Browse files
committed
feat(firestore): remove deprecated functions
1 parent 9a032b3 commit 1466627

File tree

4 files changed

+9
-171
lines changed

4 files changed

+9
-171
lines changed

packages/cloud_firestore/cloud_firestore/example/integration_test/instance_e2e.dart

Lines changed: 2 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -151,91 +151,6 @@ void runInstanceTests() {
151151
skip: kIsWeb || defaultTargetPlatform == TargetPlatform.windows,
152152
);
153153

154-
test(
155-
'setIndexConfiguration()',
156-
() async {
157-
Index index1 = Index(
158-
collectionGroup: 'bar',
159-
queryScope: QueryScope.collectionGroup,
160-
fields: [
161-
IndexField(
162-
fieldPath: 'fieldPath',
163-
order: Order.ascending,
164-
arrayConfig: ArrayConfig.contains,
165-
),
166-
],
167-
);
168-
169-
Index index2 = Index(
170-
collectionGroup: 'baz',
171-
queryScope: QueryScope.collection,
172-
fields: [
173-
IndexField(
174-
fieldPath: 'foo',
175-
arrayConfig: ArrayConfig.contains,
176-
),
177-
IndexField(
178-
fieldPath: 'bar',
179-
order: Order.descending,
180-
arrayConfig: ArrayConfig.contains,
181-
),
182-
IndexField(
183-
fieldPath: 'baz',
184-
order: Order.descending,
185-
arrayConfig: ArrayConfig.contains,
186-
),
187-
],
188-
);
189-
190-
FieldOverrides fieldOverride1 = FieldOverrides(
191-
fieldPath: 'fieldPath',
192-
indexes: [
193-
FieldOverrideIndex(
194-
queryScope: 'foo',
195-
order: Order.ascending,
196-
arrayConfig: ArrayConfig.contains,
197-
),
198-
FieldOverrideIndex(
199-
queryScope: 'bar',
200-
order: Order.descending,
201-
arrayConfig: ArrayConfig.contains,
202-
),
203-
FieldOverrideIndex(
204-
queryScope: 'baz',
205-
order: Order.descending,
206-
),
207-
],
208-
collectionGroup: 'bar',
209-
);
210-
FieldOverrides fieldOverride2 = FieldOverrides(
211-
fieldPath: 'anotherField',
212-
indexes: [
213-
FieldOverrideIndex(
214-
queryScope: 'foo',
215-
order: Order.ascending,
216-
arrayConfig: ArrayConfig.contains,
217-
),
218-
FieldOverrideIndex(
219-
queryScope: 'bar',
220-
order: Order.descending,
221-
arrayConfig: ArrayConfig.contains,
222-
),
223-
FieldOverrideIndex(
224-
queryScope: 'baz',
225-
order: Order.descending,
226-
),
227-
],
228-
collectionGroup: 'collectiongroup',
229-
);
230-
// ignore_for_file: deprecated_member_use
231-
await firestore.setIndexConfiguration(
232-
indexes: [index1, index2],
233-
fieldOverrides: [fieldOverride1, fieldOverride2],
234-
);
235-
},
236-
skip: defaultTargetPlatform == TargetPlatform.windows,
237-
);
238-
239154
test(
240155
'setIndexConfigurationFromJSON()',
241156
() async {
@@ -372,8 +287,8 @@ void runInstanceTests() {
372287
databaseId: 'web-disabled-2',
373288
);
374289

375-
// Now try using `enablePersistence()`, web only API
376-
await firestore2.enablePersistence();
290+
// Enable persistence using settings instead of deprecated enablePersistence()
291+
firestore2.settings = const Settings(persistenceEnabled: true);
377292

378293
PersistentCacheIndexManager? indexManager2 =
379294
firestore2.persistentCacheIndexManager();

packages/cloud_firestore/cloud_firestore/lib/src/firestore.dart

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ part of '../cloud_firestore.dart';
1818
class FirebaseFirestore extends FirebasePluginPlatform {
1919
FirebaseFirestore._({
2020
required this.app,
21-
@Deprecated(
22-
'`databaseURL` has been deprecated. Please use `databaseId` instead.',
23-
)
24-
required this.databaseURL,
2521
required this.databaseId,
2622
}) : super(app.name, 'plugins.flutter.io/firebase_firestore');
2723

@@ -37,23 +33,16 @@ class FirebaseFirestore extends FirebasePluginPlatform {
3733
/// Returns an instance using a specified [FirebaseApp].
3834
static FirebaseFirestore instanceFor({
3935
required FirebaseApp app,
40-
@Deprecated(
41-
'`databaseURL` has been deprecated. Please use `databaseId` instead.',
42-
)
43-
String? databaseURL,
4436
String? databaseId,
4537
}) {
46-
String firestoreDatabaseId = databaseId ?? databaseURL ?? '(default)';
38+
String firestoreDatabaseId = databaseId ?? '(default)';
4739
String cacheKey = '${app.name}|$firestoreDatabaseId';
4840
if (_cachedInstances.containsKey(cacheKey)) {
4941
return _cachedInstances[cacheKey]!;
5042
}
5143

52-
FirebaseFirestore newInstance =
53-
// Both databaseURL and databaseId are required so we have to pass both for now. We can remove databaseURL in a future release.
54-
FirebaseFirestore._(
44+
FirebaseFirestore newInstance = FirebaseFirestore._(
5545
app: app,
56-
databaseURL: firestoreDatabaseId,
5746
databaseId: firestoreDatabaseId,
5847
);
5948
_cachedInstances[cacheKey] = newInstance;
@@ -76,13 +65,6 @@ class FirebaseFirestore extends FirebasePluginPlatform {
7665
/// The [FirebaseApp] for this current [FirebaseFirestore] instance.
7766
FirebaseApp app;
7867

79-
/// Firestore Database ID for this instance. Falls back to default database: "(default)"
80-
/// This is deprecated in favor of [databaseId].
81-
@Deprecated(
82-
'`databaseURL` has been deprecated. Please use `databaseId` instead.',
83-
)
84-
String databaseURL;
85-
8668
/// Firestore Database ID for this instance. Falls back to default database: "(default)"
8769
String databaseId;
8870

@@ -124,17 +106,6 @@ class FirebaseFirestore extends FirebasePluginPlatform {
124106
return _delegate.clearPersistence();
125107
}
126108

127-
/// Enable persistence of Firestore data for web-only. Use [Settings.persistenceEnabled] for non-web platforms.
128-
/// If `enablePersistence()` is not called, it defaults to Memory cache.
129-
/// If `enablePersistence(const PersistenceSettings(synchronizeTabs: false))` is called, it persists data for a single browser tab.
130-
/// If `enablePersistence(const PersistenceSettings(synchronizeTabs: true))` is called, it persists data across multiple browser tabs.
131-
@Deprecated('Use Settings.persistenceEnabled instead.')
132-
Future<void> enablePersistence([
133-
PersistenceSettings? persistenceSettings,
134-
]) async {
135-
return _delegate.enablePersistence(persistenceSettings);
136-
}
137-
138109
LoadBundleTask loadBundle(Uint8List bundle) {
139110
return LoadBundleTask._(_delegate.loadBundle(bundle));
140111
}
@@ -351,31 +322,6 @@ class FirebaseFirestore extends FirebasePluginPlatform {
351322
return _delegate.waitForPendingWrites();
352323
}
353324

354-
/// Configures indexing for local query execution. Any previous index configuration is overridden.
355-
///
356-
/// The index entries themselves are created asynchronously. You can continue to use queries that
357-
/// require indexing even if the indices are not yet available. Query execution will automatically
358-
/// start using the index once the index entries have been written.
359-
///
360-
/// This API is now deprecated
361-
@Deprecated(
362-
'setIndexConfiguration() has been deprecated. Please use `PersistentCacheIndexManager` instead.',
363-
)
364-
Future<void> setIndexConfiguration({
365-
required List<Index> indexes,
366-
List<FieldOverrides>? fieldOverrides,
367-
}) async {
368-
String json = jsonEncode(
369-
{
370-
'indexes': indexes.map((index) => index.toMap()).toList(),
371-
'fieldOverrides':
372-
fieldOverrides?.map((index) => index.toMap()).toList() ?? [],
373-
},
374-
);
375-
376-
return _delegate.setIndexConfiguration(json);
377-
}
378-
379325
PersistentCacheIndexManager? persistentCacheIndexManager() {
380326
if (defaultTargetPlatform == TargetPlatform.windows) {
381327
throw UnimplementedError(

packages/cloud_firestore/cloud_firestore/test/cloud_firestore_test.dart

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,34 +40,25 @@ void main() {
4040
);
4141
});
4242

43-
test('databaseId and databaseURL', () {
43+
test('databaseId', () {
4444
final firestore = FirebaseFirestore.instanceFor(
45-
// ignore: deprecated_member_use_from_same_package
46-
app: Firebase.app(), databaseURL: 'foo',
45+
app: Firebase.app(),
46+
databaseId: 'foo',
4747
);
4848

49-
// ignore: deprecated_member_use_from_same_package
50-
expect(firestore.databaseURL, equals('foo'));
51-
5249
expect(firestore.databaseId, equals('foo'));
5350

5451
final firestore2 =
5552
FirebaseFirestore.instanceFor(app: Firebase.app(), databaseId: 'bar');
5653

57-
// ignore: deprecated_member_use_from_same_package
58-
expect(firestore2.databaseURL, equals('bar'));
59-
6054
expect(firestore2.databaseId, equals('bar'));
6155

6256
final firestore3 = FirebaseFirestore.instanceFor(
63-
// ignore: deprecated_member_use_from_same_package
64-
app: Firebase.app(), databaseId: 'fire', databaseURL: 'not-this',
57+
app: Firebase.app(),
58+
databaseId: 'fire',
6559
);
6660

67-
// databaseId should take precedence
6861
expect(firestore3.databaseId, equals('fire'));
69-
// ignore: deprecated_member_use_from_same_package
70-
expect(firestore3.databaseURL, equals('fire'));
7162
});
7263

7364
test('returns the correct $FirebaseApp', () {

packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,6 @@ external DocumentReferenceJsImpl doc(
111111
@staticInterop
112112
external FieldPath documentId();
113113

114-
@JS()
115-
@staticInterop
116-
@Deprecated(
117-
'This function will be removed in a future major release. Instead, set FirestoreSettings.localCache to an instance of PersistentLocalCache to turn on IndexedDb cache.',
118-
)
119-
external JSPromise enableIndexedDbPersistence(
120-
FirestoreJsImpl firestore, [
121-
PersistenceSettings? settings,
122-
]);
123-
124114
@JS()
125115
@staticInterop
126116
external JSPromise enableMultiTabIndexedDbPersistence(
@@ -743,10 +733,6 @@ abstract class FirestoreSettings {
743733
}
744734

745735
extension FirestoreSettingsExtension on FirestoreSettings {
746-
@Deprecated('Use FirestoreSettings.localCache instead.')
747-
//ignore: avoid_setters_without_getters
748-
external set cacheSizeBytes(JSNumber i);
749-
750736
//ignore: avoid_setters_without_getters
751737
external set host(JSString h);
752738

0 commit comments

Comments
 (0)