web-manager 3.1.31 → 3.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +26 -30
- package/package.json +1 -1
package/index.js
CHANGED
@@ -31,6 +31,7 @@ var debug;
|
|
31
31
|
// Shortcuts
|
32
32
|
var select;
|
33
33
|
var loadScript;
|
34
|
+
var store;
|
34
35
|
|
35
36
|
|
36
37
|
/**
|
@@ -156,6 +157,7 @@ function Manager() {
|
|
156
157
|
|
157
158
|
select = this.dom().select;
|
158
159
|
loadScript = this.dom().loadScript;
|
160
|
+
store = this.storage();
|
159
161
|
}
|
160
162
|
|
161
163
|
/**
|
@@ -227,6 +229,7 @@ function Manager() {
|
|
227
229
|
if (user) {
|
228
230
|
if (!user.isAnonymous) {
|
229
231
|
_authHandle_in(This, user);
|
232
|
+
|
230
233
|
This.notifications().subscribe().catch(function (e) {
|
231
234
|
console.error(e);
|
232
235
|
});
|
@@ -240,10 +243,22 @@ function Manager() {
|
|
240
243
|
|
241
244
|
function _authHandle_in(This, user) {
|
242
245
|
// This.log('_authHandle_in', user);
|
243
|
-
if (This.properties.page.status.didSignUp) {
|
246
|
+
// if (This.properties.page.status.didSignUp) {
|
247
|
+
var didSignUp = 'auth.didSignUp';
|
248
|
+
var done;
|
249
|
+
var hoursSinceCreation = Math.abs(new Date() - new Date(+user.metadata.a)) / 36e5;
|
250
|
+
|
251
|
+
function _done() {
|
252
|
+
if (!done) {
|
253
|
+
done = true;
|
254
|
+
store.set(didSignUp, true)
|
255
|
+
_authHandle_in_normal(This, user);
|
256
|
+
}
|
257
|
+
}
|
258
|
+
|
259
|
+
if (!store.get(didSignUp) && hoursSinceCreation < 0.5) {
|
244
260
|
user.getIdToken(false)
|
245
261
|
.then(function(token) {
|
246
|
-
var done;
|
247
262
|
|
248
263
|
fetch('https://us-central1-' + This.properties.options.libraries.firebase_app.config.projectId + '.cloudfunctions.net/bm_api', {
|
249
264
|
method: 'POST',
|
@@ -252,43 +267,24 @@ function Manager() {
|
|
252
267
|
command: 'user:sign-up',
|
253
268
|
payload: {
|
254
269
|
newsletterSignUp: select('.auth-newsletter-input').getValue(),
|
255
|
-
affiliateCode:
|
270
|
+
affiliateCode: store.get('auth.affiliateCode', ''),
|
256
271
|
},
|
257
272
|
}),
|
258
273
|
})
|
259
274
|
.catch(function () {})
|
260
|
-
.finally(
|
261
|
-
if (!done) {
|
262
|
-
done = true;
|
263
|
-
_authHandle_in_normal(This, user);
|
264
|
-
}
|
265
|
-
});
|
275
|
+
.finally(_done);
|
266
276
|
|
267
277
|
setTimeout(function () {
|
268
|
-
|
269
|
-
done = true;
|
270
|
-
_authHandle_in_normal(This, user);
|
271
|
-
}
|
278
|
+
_done()
|
272
279
|
}, 5000);
|
273
280
|
|
274
281
|
})
|
275
282
|
.catch(function(error) {
|
276
283
|
console.error(error);
|
277
|
-
|
284
|
+
_done();
|
278
285
|
});
|
279
|
-
|
280
|
-
// } else if (This.properties.page.status.didSignIn) {
|
281
|
-
// This.notifications().isSubscribed(function (status) {
|
282
|
-
// if (status) {
|
283
|
-
// This.notifications().subscribe()
|
284
|
-
// .then(function () {
|
285
|
-
//
|
286
|
-
// })
|
287
|
-
// }
|
288
|
-
// })
|
289
|
-
// _authHandle_in_normal(This, user);
|
290
286
|
} else {
|
291
|
-
|
287
|
+
_done();
|
292
288
|
}
|
293
289
|
}
|
294
290
|
|
@@ -641,7 +637,7 @@ function Manager() {
|
|
641
637
|
var pagePathname = window.location.pathname;
|
642
638
|
var qsAff = pageQueryString.get('aff');
|
643
639
|
if (qsAff) {
|
644
|
-
|
640
|
+
store.set('auth.affiliateCode', qsAff);
|
645
641
|
}
|
646
642
|
var qsRedirect = pageQueryString.get('redirect');
|
647
643
|
if (qsRedirect && This.isValidRedirectUrl(qsRedirect)) {
|
@@ -994,7 +990,7 @@ function Manager() {
|
|
994
990
|
setAuthButtonDisabled(mode, true);
|
995
991
|
firebase.auth().createUserWithEmailAndPassword(email, password)
|
996
992
|
.then(function(credential) {
|
997
|
-
This.properties.page.status.didSignUp = true;
|
993
|
+
// This.properties.page.status.didSignUp = true;
|
998
994
|
// This.log('Good signup');
|
999
995
|
// signupButtonDisabled(false);
|
1000
996
|
})
|
@@ -1081,7 +1077,7 @@ function Manager() {
|
|
1081
1077
|
})
|
1082
1078
|
.then(function (token) {
|
1083
1079
|
var user = This.auth().getUser();
|
1084
|
-
var localSubscription =
|
1080
|
+
var localSubscription = store.get('notifications', {});
|
1085
1081
|
var localHash = localSubscription.token + '|' + localSubscription.uid;
|
1086
1082
|
var userHash = token + '|' + user.uid;
|
1087
1083
|
// console.log('user', user);
|
@@ -1101,7 +1097,7 @@ function Manager() {
|
|
1101
1097
|
function saveLocal() {
|
1102
1098
|
// console.log('---------saveLocal');
|
1103
1099
|
// This.log('Saved local token: ', token);
|
1104
|
-
|
1100
|
+
store.set('notifications', {uid: user.uid, token: token, lastSynced: timestamp});
|
1105
1101
|
}
|
1106
1102
|
|
1107
1103
|
function saveServer(doc) {
|
package/package.json
CHANGED