Skip to content

Commit

Permalink
feat(afs): Support Firebase 5.5 and Firestore PersistenceSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdaniels committed Oct 17, 2018
1 parent d6f59c7 commit a9cf1ca
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 66 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularfire2",
"version": "5.0.2",
"version": "5.1.0",
"description": "The official library of Firebase and Angular.",
"private": true,
"scripts": {
Expand All @@ -12,7 +12,7 @@
"delayed_karma": "sleep 10 && karma start",
"build": "rm -rf dist && node tools/build.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
"build:wrapper": "npm i --prefix wrapper && VERSION=5.0.2 npm run --prefix wrapper build"
"build:wrapper": "npm i --prefix wrapper && VERSION=5.1.0 npm run --prefix wrapper build"
},
"keywords": [
"angular",
Expand All @@ -35,7 +35,7 @@
"@angular/core": "^6.0.0",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"firebase": "^5.0.3",
"firebase": "^5.5.0",
"rxjs": "^6.0.0",
"ws": "^3.3.2",
"xhr2": "^0.1.4",
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/firestore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('AngularFirestore', () => {
TestBed.configureTestingModule({
imports: [
AngularFireModule.initializeApp(COMMON_CONFIG),
AngularFirestoreModule.enablePersistence()
AngularFirestoreModule.enablePersistence({experimentalTabSynchronization: true})
]
});
inject([FirebaseApp, AngularFirestore], (_app: FirebaseApp, _afs: AngularFirestore) => {
Expand Down
8 changes: 4 additions & 4 deletions src/firestore/firestore.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { InjectionToken, NgZone, PLATFORM_ID, Injectable, Inject, Optional } from '@angular/core';

import { Observable, of, from } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { firestore } from 'firebase';

import { Settings, CollectionReference, DocumentReference, QueryFn, AssociatedReference } from './interfaces';
import { Settings, PersistenceSettings, CollectionReference, DocumentReference, QueryFn, AssociatedReference } from './interfaces';
import { AngularFirestoreDocument } from './document/document';
import { AngularFirestoreCollection } from './collection/collection';

Expand All @@ -15,6 +13,7 @@ import { isPlatformBrowser } from '@angular/common';
* The value of this token determines whether or not the firestore will have persistance enabled
*/
export const EnablePersistenceToken = new InjectionToken<boolean>('angularfire2.enableFirestorePersistence');
export const PersistenceSettingsToken = new InjectionToken<PersistenceSettings|undefined>('angularfire2.firestore.persistenceSettings');
export const FirestoreSettingsToken = new InjectionToken<Settings>('angularfire2.firestore.settings');

export const DefaultFirestoreSettings = {timestampsInSnapshots: true} as Settings;
Expand Down Expand Up @@ -108,6 +107,7 @@ export class AngularFirestore {
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|undefined,
@Optional() @Inject(EnablePersistenceToken) shouldEnablePersistence: boolean,
@Optional() @Inject(PersistenceSettingsToken) persistenceSettings: PersistenceSettings|undefined,
@Optional() @Inject(FirestoreSettingsToken) settings: Settings,
@Inject(PLATFORM_ID) platformId: Object,
zone: NgZone
Expand All @@ -125,7 +125,7 @@ export class AngularFirestore {
// https://github.com/firebase/firebase-js-sdk/issues/608
const enablePersistence = () => {
try {
return from(this.firestore.enablePersistence().then(() => true, () => false));
return from(this.firestore.enablePersistence(persistenceSettings).then(() => true, () => false));
} catch(e) {
return of(false);
}
Expand Down
4 changes: 2 additions & 2 deletions src/firestore/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Subscriber } from 'rxjs';
import { firestore } from 'firebase';
import { firestore } from 'firebase/app';

export type Settings = firestore.Settings;
export type CollectionReference = firestore.CollectionReference;
export type DocumentReference = firestore.DocumentReference;

export type PersistenceSettings = firestore.PersistenceSettings;
export type DocumentChangeType = firestore.DocumentChangeType;
export type SnapshotOptions = firestore.SnapshotOptions;
export type FieldPath = firestore.FieldPath;
Expand Down
116 changes: 60 additions & 56 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,63 +53,63 @@
version "0.3.2"
resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.3.2.tgz#a92dc544290e2893bd8c02a81e684dae3d8e7c85"

"@firebase/app@0.3.3":
version "0.3.3"
resolved "https://registry.yarnpkg.com/@firebase/app/-/app-0.3.3.tgz#cb8df89495e4409e92ab30c0068b9e0641a6db81"
"@firebase/app@0.3.4":
version "0.3.4"
resolved "https://registry.yarnpkg.com/@firebase/app/-/app-0.3.4.tgz#610c931bac191598b383812b36c1d2cc52316d31"
dependencies:
"@firebase/app-types" "0.3.2"
"@firebase/util" "0.2.1"
"@firebase/util" "0.2.2"
dom-storage "2.1.0"
tslib "1.9.0"
xmlhttprequest "1.8.0"

"@firebase/auth-types@0.3.3":
version "0.3.3"
resolved "https://registry.yarnpkg.com/@firebase/auth-types/-/auth-types-0.3.3.tgz#950a68bdae1e1e37ece054ff69ee0082c5ecabab"
"@firebase/auth-types@0.3.4":
version "0.3.4"
resolved "https://registry.yarnpkg.com/@firebase/auth-types/-/auth-types-0.3.4.tgz#253b1b2d9b520a0b945d4617c8418f0f19a4159f"

"@firebase/auth@0.5.3":
version "0.5.3"
resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-0.5.3.tgz#4f0d83cd5a7c173d3a7a06f904bb1084acd8a0c4"
"@firebase/auth@0.7.8":
version "0.7.8"
resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-0.7.8.tgz#3725824f8fd9c12c5fc497b41da1e5ce587b98d1"
dependencies:
"@firebase/auth-types" "0.3.3"
"@firebase/auth-types" "0.3.4"

"@firebase/database-types@0.3.2":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.3.2.tgz#70611a64dd460e0e253c7427f860d56a1afd86fe"

"@firebase/database@0.3.3":
version "0.3.3"
resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.3.3.tgz#01123d4e0f8cb020e685ead27d795ef8794b2991"
"@firebase/database@0.3.6":
version "0.3.6"
resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.3.6.tgz#95167bc5d8454ade1619e6b74b823b08370ff2d1"
dependencies:
"@firebase/database-types" "0.3.2"
"@firebase/logger" "0.1.1"
"@firebase/util" "0.2.1"
"@firebase/util" "0.2.2"
faye-websocket "0.11.1"
tslib "1.9.0"

"@firebase/firestore-types@0.4.3":
version "0.4.3"
resolved "https://registry.yarnpkg.com/@firebase/firestore-types/-/firestore-types-0.4.3.tgz#0baa4f68aa8889474f582320af577f1e9a78fab6"
"@firebase/firestore-types@0.7.0":
version "0.7.0"
resolved "https://registry.yarnpkg.com/@firebase/firestore-types/-/firestore-types-0.7.0.tgz#bded7892868cf6b189a121d0f0cec468f1609995"

"@firebase/firestore@0.5.4":
version "0.5.4"
resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-0.5.4.tgz#26f67fa038ffd74ef849019728c59d4a5590a324"
"@firebase/firestore@0.8.4":
version "0.8.4"
resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-0.8.4.tgz#2cb35180c002b4ab49e822239c3868c16a645d94"
dependencies:
"@firebase/firestore-types" "0.4.3"
"@firebase/firestore-types" "0.7.0"
"@firebase/logger" "0.1.1"
"@firebase/webchannel-wrapper" "0.2.8"
grpc "1.11.3"
"@firebase/webchannel-wrapper" "0.2.11"
grpc "1.13.1"
tslib "1.9.0"

"@firebase/functions-types@0.1.3":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@firebase/functions-types/-/functions-types-0.1.3.tgz#17bc08a51f92b4eb5d1498f18b363f6c0e3a2df8"
"@firebase/functions-types@0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@firebase/functions-types/-/functions-types-0.2.0.tgz#936d3f77957431a8ef1817975fee26464575802b"

"@firebase/functions@0.2.4":
version "0.2.4"
resolved "https://registry.yarnpkg.com/@firebase/functions/-/functions-0.2.4.tgz#4d7acbc1feb8a1503f12072e40ea797d42bdb6b7"
"@firebase/functions@0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@firebase/functions/-/functions-0.3.1.tgz#9b25e84176d4395946ed7a90fec9fdef8032f56a"
dependencies:
"@firebase/functions-types" "0.1.3"
"@firebase/functions-types" "0.2.0"
"@firebase/messaging-types" "0.2.3"
isomorphic-fetch "2.2.1"
tslib "1.9.0"
Expand All @@ -122,12 +122,12 @@
version "0.2.3"
resolved "https://registry.yarnpkg.com/@firebase/messaging-types/-/messaging-types-0.2.3.tgz#ed2949129dc5b3b0adff23ae1e1010bc7806f974"

"@firebase/messaging@0.3.4":
version "0.3.4"
resolved "https://registry.yarnpkg.com/@firebase/messaging/-/messaging-0.3.4.tgz#374d8e19e8fa900d81bc30f5d4e8946bd1c336a7"
"@firebase/messaging@0.3.6":
version "0.3.6"
resolved "https://registry.yarnpkg.com/@firebase/messaging/-/messaging-0.3.6.tgz#30662779ae5b2812da090da7607e7293cfb22a8e"
dependencies:
"@firebase/messaging-types" "0.2.3"
"@firebase/util" "0.2.1"
"@firebase/util" "0.2.2"
tslib "1.9.0"

"@firebase/polyfill@0.3.3":
Expand All @@ -149,15 +149,15 @@
"@firebase/storage-types" "0.2.3"
tslib "1.9.0"

"@firebase/util@0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@firebase/util/-/util-0.2.1.tgz#b59a2fbf14fce21401cbebf776a3e0260b591380"
"@firebase/util@0.2.2":
version "0.2.2"
resolved "https://registry.yarnpkg.com/@firebase/util/-/util-0.2.2.tgz#fdd57ca21b587564c0a3a032f55092633f390a30"
dependencies:
tslib "1.9.0"

"@firebase/webchannel-wrapper@0.2.8":
version "0.2.8"
resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.2.8.tgz#38a936b60b898a1ad0f3719543ff1a1031f60f8b"
"@firebase/webchannel-wrapper@0.2.11":
version "0.2.11"
resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.2.11.tgz#32a853fad9974cbbc9fc766ec5699a18b22ccee6"

"@types/estree@0.0.39":
version "0.0.39"
Expand Down Expand Up @@ -1897,16 +1897,16 @@ fined@^1.0.1:
object.pick "^1.2.0"
parse-filepath "^1.0.1"

firebase@^5.0.3:
version "5.0.4"
resolved "https://registry.yarnpkg.com/firebase/-/firebase-5.0.4.tgz#f367c80531c1a8a4ef82b6537b2a6bd92685e226"
firebase@^5.5.0:
version "5.5.4"
resolved "https://registry.yarnpkg.com/firebase/-/firebase-5.5.4.tgz#6c6c9c829c1c223dd6bc9c5a7805a5ebcaf36ae2"
dependencies:
"@firebase/app" "0.3.3"
"@firebase/auth" "0.5.3"
"@firebase/database" "0.3.3"
"@firebase/firestore" "0.5.4"
"@firebase/functions" "0.2.4"
"@firebase/messaging" "0.3.4"
"@firebase/app" "0.3.4"
"@firebase/auth" "0.7.8"
"@firebase/database" "0.3.6"
"@firebase/firestore" "0.8.4"
"@firebase/functions" "0.3.1"
"@firebase/messaging" "0.3.6"
"@firebase/polyfill" "0.3.3"
"@firebase/storage" "0.2.3"

Expand Down Expand Up @@ -2284,14 +2284,14 @@ graceful-fs@~1.2.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"

grpc@1.11.3:
version "1.11.3"
resolved "https://registry.yarnpkg.com/grpc/-/grpc-1.11.3.tgz#46093bb17702b9fc1b099789695e6f47d6487129"
grpc@1.13.1:
version "1.13.1"
resolved "https://registry.yarnpkg.com/grpc/-/grpc-1.13.1.tgz#9b5c49d4e56309b6e3bd631f8948b7b298d88790"
dependencies:
lodash "^4.15.0"
lodash "^4.17.5"
nan "^2.0.0"
node-pre-gyp "^0.10.0"
protobufjs "^5.0.0"
protobufjs "^5.0.3"

gulp-jasmine@^2.2.1:
version "2.4.2"
Expand Down Expand Up @@ -3343,6 +3343,10 @@ lodash@^4.0.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.2.1, l
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"

lodash@^4.17.5:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"

lodash@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551"
Expand Down Expand Up @@ -4244,7 +4248,7 @@ promisify-call@^2.0.2:
dependencies:
with-callback "^1.0.2"

protobufjs@^5.0.0:
protobufjs@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-5.0.3.tgz#e4dfe9fb67c90b2630d15868249bcc4961467a17"
dependencies:
Expand Down

0 comments on commit a9cf1ca

Please sign in to comment.