web-manager 3.2.67 → 3.2.69

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/index.js +26 -32
  2. package/lib/account.js +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -627,7 +627,7 @@ Manager.prototype.init = function(configuration, callback) {
627
627
  self.properties.global.app = configuration.global.app;
628
628
  self.properties.global.version = configuration.global.version;
629
629
  self.properties.global.url = configuration.global.url;
630
- self.properties.global.buildTime = new Date((+configuration.global.buildTime * 1000) || new Date())
630
+ self.properties.global.buildTime = new Date((+configuration.global.buildTime * 1000) || new Date());
631
631
  self.properties.global.cacheBreaker = configuration.global.cacheBreaker;
632
632
 
633
633
  self.properties.global.brand = configuration.global.brand;
@@ -1018,20 +1018,27 @@ Manager.prototype.notifications = function(options) {
1018
1018
 
1019
1019
  return {
1020
1020
  isSubscribed: function () {
1021
- // self.log('isSubscribed()');
1022
1021
  return new Promise(function(resolve, reject) {
1023
- if (!supported || Notification.permission !== 'granted') {return resolve(false)};
1024
- return resolve(true);
1022
+ // Log
1023
+ // self.log('isSubscribed()');
1024
+
1025
+ // Check if subscribed
1026
+ return resolve(supported && Notification.permission === 'granted');
1025
1027
  })
1026
1028
  },
1027
1029
  subscribe: function () {
1028
- // self.log('subscribe()');
1029
1030
  return new Promise(function(resolve, reject) {
1030
- // var subscribed = !self.notifications().isSubscribed();
1031
+ // Log
1032
+ // self.log('subscribe()');
1033
+
1034
+ // Check if supported
1031
1035
  if (!supported) {
1032
1036
  return resolve(false)
1033
1037
  }
1034
- firebase.messaging().getToken({
1038
+
1039
+ // Ask for permission
1040
+ firebase.messaging()
1041
+ .getToken({
1035
1042
  serviceWorkerRegistration: self.properties.references.serviceWorker,
1036
1043
  })
1037
1044
  .then(function (token) {
@@ -1051,7 +1058,7 @@ Manager.prototype.notifications = function(options) {
1051
1058
  if (localHash !== userHash || dateDifference > 1) {
1052
1059
  var timestamp = currentDate.toISOString();
1053
1060
  var timestampUNIX = Math.floor((+new Date(timestamp)) / 1000);
1054
- var subscriptionRef = firebase.firestore().doc('notifications/subscriptions/all/' + token);
1061
+ var subscriptionRef = firebase.firestore().doc('notifications/' + token);
1055
1062
 
1056
1063
  function saveLocal() {
1057
1064
  // console.log('---------saveLocal');
@@ -1060,38 +1067,25 @@ Manager.prototype.notifications = function(options) {
1060
1067
  }
1061
1068
 
1062
1069
  function saveServer(doc) {
1063
- // console.log('-------saveServer', !doc.exists, !self.utilities().get(doc.data(), 'link.user.data.uid', ''), user.uid);
1064
1070
  // Run if it (DOES NOT EXIST on server) OR (it does AND the uid field is null AND the current user is not null)
1065
- if (!doc.exists || (doc.exists && !self.utilities().get(doc.data(), 'link.user.data.uid', '') && user.uid)) {
1071
+ if (!doc.exists || (doc.exists && !self.utilities().get(doc.data(), 'owner.uid', '') && user.uid)) {
1066
1072
  subscriptionRef
1067
1073
  .set(
1068
1074
  {
1069
- meta: {
1070
- dateSubscribed: {
1071
- timestamp: timestamp,
1072
- timestampUNIX: timestampUNIX
1073
- },
1074
- url: window.location.href,
1075
+ created: {
1076
+ timestamp: timestamp,
1077
+ timestampUNIX: timestampUNIX,
1075
1078
  },
1076
- token: token,
1077
- link: {
1078
- user: {
1079
- lastLinked: {
1080
- timestamp: timestamp,
1081
- timestampUNIX: timestampUNIX
1082
- },
1083
- pk: user.uid,
1084
- data: {
1085
- uid: user.uid,
1086
- email: user.email
1087
- }
1088
- }
1079
+ owner: {
1080
+ uid: user.uid,
1089
1081
  },
1090
- tags: ['general']
1082
+ token: token,
1083
+ url: window.location.href,
1084
+ tags: ['general'],
1091
1085
  },
1092
1086
  {
1093
- merge: true
1094
- }
1087
+ merge: true,
1088
+ },
1095
1089
  )
1096
1090
  .then(function(data) {
1097
1091
  // self.log('Updated token: ', token);
package/lib/account.js CHANGED
@@ -70,7 +70,7 @@ Account.prototype.delete = function (options) {
70
70
  } else {
71
71
  user.getIdToken(false)
72
72
  .then(function(token) {
73
- fetch(self.Manager.properties.properties.global.functionsUrl + '/bm_api', {
73
+ fetch(self.Manager.properties.global.functionsUrl + '/bm_api', {
74
74
  // fetch('http://localhost:5001/optiic-api/us-central1/bm_api', {
75
75
  method: 'POST',
76
76
  headers: { 'Content-Type': 'application/json' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.67",
3
+ "version": "3.2.69",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "index.js",
6
6
  "scripts": {