Merge branch 'v3.3.x'

# Conflicts:
#	tests/ios/Podfile.lock
This commit is contained in:
Chris Bianca 2018-03-08 11:53:31 +00:00
commit a82afe92d6
6 changed files with 42 additions and 30 deletions

View File

@ -16,8 +16,8 @@ import { getNativeModule } from '../../utils/native';
type Command = {
type: 'set' | 'update' | 'delete',
path: string,
data: ?{ [string]: any },
options: ?{ merge: boolean },
data?: { [string]: any },
options?: SetOptions | {},
};
type SetOptions = {

View File

@ -19,9 +19,9 @@ const generateTransactionId = (): number => transactionId++;
export type TransactionMeta = {
id: number,
stack: Array<string>,
reject: null | Function,
resolve: null | Function,
stack: string[],
reject?: Function,
resolve?: Function,
transaction: Transaction,
updateFunction: (transaction: Transaction) => Promise<any>,
};
@ -37,7 +37,12 @@ type TransactionEvent = {
*/
export default class TransactionHandler {
_firestore: Firestore;
_pending: { [number]: TransactionMeta };
_pending: {
[number]: {
meta: TransactionMeta,
transaction: Transaction,
},
};
constructor(firestore: Firestore) {
this._pending = {};
@ -62,10 +67,9 @@ export default class TransactionHandler {
updateFunction: (transaction: Transaction) => Promise<any>
): Promise<any> {
const id = generateTransactionId();
const meta = {
// $FlowExpectedError: Transaction has to be populated
const meta: TransactionMeta = {
id,
reject: null,
resolve: null,
updateFunction,
stack: new Error().stack
.split('\n')
@ -73,8 +77,10 @@ export default class TransactionHandler {
.join('\n'),
};
meta.transaction = new Transaction(this._firestore, meta);
this._pending[id] = meta;
this._pending[id] = {
meta,
transaction: new Transaction(this._firestore, meta),
};
// deferred promise
return new Promise((resolve, reject) => {
@ -145,7 +151,8 @@ export default class TransactionHandler {
// abort if no longer exists js side
if (!this._pending[id]) return this._remove(id);
const { updateFunction, transaction, reject } = this._pending[id];
const { meta, transaction } = this._pending[id];
const { updateFunction, reject } = meta;
// clear any saved state from previous transaction runs
transaction._prepare();
@ -178,6 +185,7 @@ export default class TransactionHandler {
// update is failed when either the users updateFunction
// throws an error or rejects a promise
if (updateFailed) {
// $FlowExpectedError: Reject will always be present
return reject(finalError);
}
@ -201,17 +209,20 @@ export default class TransactionHandler {
*/
_handleError(event: TransactionEvent) {
const { id, error } = event;
const meta = this._pending[id];
const { meta } = this._pending[id];
if (meta) {
if (meta && error) {
const { code, message } = error;
// build a JS error and replace its stack
// with the captured one at start of transaction
// so it's actually relevant to the user
const errorWithStack = new Error(message);
// $FlowExpectedError: code is needed for Firebase errors
errorWithStack.code = code;
// $FlowExpectedError: stack should be a stack trace
errorWithStack.stack = meta.stack;
// $FlowExpectedError: Reject will always be present
meta.reject(errorWithStack);
}
}
@ -224,10 +235,11 @@ export default class TransactionHandler {
*/
_handleComplete(event: TransactionEvent) {
const { id } = event;
const meta = this._pending[id];
const { meta, transaction } = this._pending[id];
if (meta) {
const pendingResult = meta.transaction._pendingResult;
const pendingResult = transaction._pendingResult;
// $FlowExpectedError: Resolve will always be present
meta.resolve(pendingResult);
}
}

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "react-native-firebase",
"version": "3.3.0",
"version": "3.3.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "react-native-firebase",
"version": "3.3.0",
"version": "3.3.1",
"author": "Invertase <contact@invertase.io> (http://invertase.io)",
"description": "A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Messaging (FCM), Remote Config, Storage and Performance.",
"main": "dist/index.js",

View File

@ -164,7 +164,7 @@ PODS:
- React/Core
- React/fishhook
- React/RCTBlob
- RNFirebase (3.3.0):
- RNFirebase (3.3.1):
- React
- yoga (0.52.3.React)
@ -192,11 +192,11 @@ DEPENDENCIES:
EXTERNAL SOURCES:
React:
:path: "../node_modules/react-native"
:path: ../node_modules/react-native
RNFirebase:
:path: "../../ios/RNFirebase.podspec"
:path: ../../ios/RNFirebase.podspec
yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"
:path: ../node_modules/react-native/ReactCommon/yoga
SPEC CHECKSUMS:
BoringSSL: 32764dbaf5f5888cf51fbaa172a010126b41bcd4
@ -224,13 +224,13 @@ SPEC CHECKSUMS:
gRPC-ProtoRPC: 22712b23eb1bda656a59715fa5c1da0ea1493ea4
gRPC-RxLibrary: a41a4652d220f230ba1c0491a94ce2ee04c6180a
GTMSessionFetcher: 390ea358e5a0d0133153806f744662dad933d06b
leveldb-library: '08cba283675b7ed2d99629a4bc5fd052cd2bb6a5'
leveldb-library: 08cba283675b7ed2d99629a4bc5fd052cd2bb6a5
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03
React: c0dfd2dfc970019d1ae7d48bf24cef530992e079
RNFirebase: 056b672391f3e7b572d8ef221c84603970e0c114
yoga: f45a46b966e1eb0c7a532cfd4beec5b97332ba48
React: 43e97926f429d846050880666de1809e22dd5cc5
RNFirebase: dff98ceb517ef0b5e1858deb59eca186acc6edb0
yoga: 55da126afc384965b96bff46652464373b330add
PODFILE CHECKSUM: d20e53c395f89ffcfe49e809a8fd7f54beca0700
COCOAPODS: 1.2.1
COCOAPODS: 1.4.0

View File

@ -1006,7 +1006,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
6AE1012F46FF8A4D1D818A12 /* [CP] Copy Pods Resources */ = {
@ -1016,11 +1016,11 @@
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-ReactNativeFirebaseDemo/Pods-ReactNativeFirebaseDemo-resources.sh",
"$PODS_CONFIGURATION_BUILD_DIR/gRPC/gRPCCertificates.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;