Skip to content

Commit d9fea62

Browse files
committed
WIP: fix merge conflicts
1 parent 8001820 commit d9fea62

File tree

7 files changed

+19
-13
lines changed

7 files changed

+19
-13
lines changed

src/database/core/PersistentConnection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ export class PersistentConnection extends ServerActions {
817817
// Puts depend on having received the corresponding data update from the server before they complete, so we must
818818
// make sure to send listens before puts.
819819
forEach(this.listens_, (pathString: string, queries: Object) => {
820-
forEach(queries, function (key: string, listenSpec: ListenSpec) {
820+
forEach(queries, (key: string, listenSpec: ListenSpec) => {
821821
this.sendListen_(listenSpec);
822822
});
823823
});

src/database/core/Repo.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ const INTERRUPT_REASON = 'repo_interrupt';
3434
* A connection to a single data repository.
3535
*/
3636
export class Repo {
37-
/** @type {!Database} */
38-
database: Database;
3937
dataUpdateCount = 0;
4038
private infoSyncTree_: SyncTree;
4139
private serverSyncTree_: SyncTree;
@@ -51,6 +49,7 @@ export class Repo {
5149
private abortTransactions_: (path: Path) => Path;
5250
private rerunTransactions_: (changedPath: Path) => Path;
5351
private interceptServerDataCallback_: ((a: string, b: any) => void) | null = null;
52+
private __database: Database;
5453

5554
// A list of data pieces and paths to be set when this client disconnects.
5655
private onDisconnect_ = new SparseSnapshotTree();
@@ -553,5 +552,9 @@ export class Repo {
553552
});
554553
}
555554
}
555+
556+
get database(): Database {
557+
return this.__database || (this.__database = new Database(this));
558+
}
556559
}
557560

src/database/core/Repo_transaction.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ export enum TransactionStatus {
5555
* @const
5656
* @private
5757
*/
58-
const MAX_TRANSACTION_RETRIES_ = 25;
59-
58+
(Repo as any).MAX_TRANSACTION_RETRIES_ = 25;
6059

6160
/**
6261
* @typedef {{
@@ -401,7 +400,7 @@ Repo.prototype.startTransaction = function (path: Path,
401400
abortReason = transaction.abortReason;
402401
events = events.concat(this.serverSyncTree_.ackUserWrite(transaction.currentWriteId, true));
403402
} else if (transaction.status === TransactionStatus.RUN) {
404-
if (transaction.retryCount >= MAX_TRANSACTION_RETRIES_) {
403+
if (transaction.retryCount >= (Repo as any).MAX_TRANSACTION_RETRIES_) {
405404
abortTransaction = true;
406405
abortReason = 'maxretry';
407406
events = events.concat(this.serverSyncTree_.ackUserWrite(transaction.currentWriteId, true));

src/database/core/WriteTree.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ export class WriteTree {
385385
if (!toIterate.isEmpty() && !toIterate.isLeafNode()) {
386386
const nodes = [];
387387
const cmp = index.getCompare();
388-
const iter = reverse ? (toIterateas ChildrenNode).getReverseIteratorFrom(startPost, index) :
389-
(toIterateas ChildrenNode).getIteratorFrom(startPost, index);
388+
const iter = reverse ? (toIterate as ChildrenNode).getReverseIteratorFrom(startPost, index) :
389+
(toIterate as ChildrenNode).getIteratorFrom(startPost, index);
390390
let next = iter.getNext();
391391
while (next && nodes.length < count) {
392392
if (cmp(next, startPost) !== 0) {

src/database/core/util/SortedMap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export class LLRBNode<K, V> {
303303
} else {
304304
smallest = (n.right as LLRBNode<K,V>).min_();
305305
n = n.copy(smallest.key, smallest.value, null, null,
306-
(n.rightas LLRBNode<K,V>).removeMin_());
306+
(n.right as LLRBNode<K,V>).removeMin_());
307307
}
308308
}
309309
n = n.copy(null, null, null, null, n.right.remove(key, comparator));

tests/database/helpers/util.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,16 @@ export function getSnap(path) {
188188
path.once('value', callback);
189189
return snap;
190190
}
191+
191192
export function getVal(path) {
192193
const snap = getSnap(path);
193194
return snap ? snap.val() : undefined;
194195
}
196+
195197
export function canCreateExtraConnections() {
196198
return globalScope.MozWebSocket || globalScope.WebSocket;
197199
}
200+
198201
export function buildObjFromKey(key) {
199202
const keys = key.split('.');
200203
const obj = {};
@@ -206,10 +209,11 @@ export function buildObjFromKey(key) {
206209
}
207210
return obj;
208211
}
212+
209213
export function testRepoInfo(url) {
210-
const regex = /https:\/\/(.*).firebaseio.com/;
214+
const regex = /https?:\/\/(.*).firebaseio.com/;
211215
const match = url.match(regex);
212216
if (!match) throw new Error('Couldnt get Namespace from passed URL');
213217
const [,ns] = match;
214-
return new ConnectionTarget(`${ns}.firebaseio.com`, false, ns, false);
218+
return new ConnectionTarget(`${ns}.firebaseio.com`, true, ns, false);
215219
}

tests/database/repoinfo.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ describe('RepoInfo', function() {
1616
urlParams[VERSION_PARAM] = PROTOCOL_VERSION;
1717
urlParams[LAST_SESSION_PARAM] = 'test';
1818

19-
const websocketUrl = repoInfo.connectionURL(CONSTANTS.WEBSOCKET, urlParams);
19+
const websocketUrl = repoInfo.connectionURL(WEBSOCKET, urlParams);
2020
expect(websocketUrl).to.equal('wss://test-ns.firebaseio.com/.ws?v=5&ls=test');
2121

22-
const longPollingUrl = repoInfo.connectionURL(CONSTANTS.LONG_POLLING, urlParams);
22+
const longPollingUrl = repoInfo.connectionURL(LONG_POLLING, urlParams);
2323
expect(longPollingUrl).to.equal('https://test-ns.firebaseio.com/.lp?v=5&ls=test');
2424
});
2525
});

0 commit comments

Comments
 (0)