Skip to content

Commit 51e6780

Browse files
committed
Error: XMLHttpRequest is not defined - Blocked due to this issue firebase/firebase-js-sdk#349
1 parent 7fd5d80 commit 51e6780

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/sw.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,21 @@ workbox.routing.registerRoute(
3434
}
3535
);
3636

37-
const auth = new AuthApiImpl();
38-
auth.getUserId().then(
39-
function (userId) {
40-
if (userId) {
41-
const remoteSync = new DataSynchronizer (new IndexedDb(), new FirestoreApi(userId));
42-
self.addEventListener('sync', event => {
43-
if (event.tag === SyncDirection.LocalToRemote) {
37+
self.addEventListener('sync', event => {
38+
if (event.tag === SyncDirection.LocalToRemote) {
39+
40+
const auth = new AuthApiImpl();
41+
auth.getUserId().then(
42+
function (userId) {
43+
if (userId) {
44+
const remoteSync = new DataSynchronizer (new IndexedDb(), new FirestoreApi(userId));
4445
remoteSync.sync();
4546
}
46-
});
47-
48-
}
47+
}
48+
)
4949
}
50-
)
50+
});
51+
5152

5253
/** TODO use it to retry firestore failed requests
5354
*

src/views/Sync.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function Sync(props: HeaderNotifierProps&RouterProps) {
5454
console.error(error);
5555
}
5656
if (uid) {
57-
await btApp.cleanupStorage();
57+
await btApp.refreshStores();
5858
}
5959
setIsLoggedIn(!!uid);
6060
}
@@ -74,7 +74,7 @@ export function Sync(props: HeaderNotifierProps&RouterProps) {
7474
setError('There were some problems signing out');
7575
console.error(error);
7676
}
77-
await btApp.cleanupStorage();
77+
await btApp.refreshStores();
7878
setIsLoggedIn(!!uid);
7979
}
8080

0 commit comments

Comments
 (0)