Browse Source

fix(vpaas): Store billing id in parent lolcaStorage on Safari

master
Vlad Piersec 4 years ago
parent
commit
23574e9edc

+ 3
- 3
package-lock.json View File

@@ -3325,9 +3325,9 @@
3325 3325
       }
3326 3326
     },
3327 3327
     "@jitsi/js-utils": {
3328
-      "version": "1.0.3",
3329
-      "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-1.0.3.tgz",
3330
-      "integrity": "sha512-m6mZz7R716mHP21lTKQffyM0nNFu3Fe/EHCaOVLFY/vdPsaUl9DhypJqtPIYzRUfPnmnugdaxcxrUeSZQXQzVA==",
3328
+      "version": "1.0.5",
3329
+      "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-1.0.5.tgz",
3330
+      "integrity": "sha512-1APQyuqQaYDR+W7cdgzsaBo6x8dpF8sfelcBf3ngNU3Jd+DzuuwUvCMTbr2+cCuy6w59ZAuQ7e2ixCnnOXOW4Q==",
3331 3331
       "requires": {
3332 3332
         "bowser": "2.7.0",
3333 3333
         "js-md5": "0.7.3"

+ 1
- 1
package.json View File

@@ -32,7 +32,7 @@
32 32
     "@atlaskit/theme": "7.0.2",
33 33
     "@atlaskit/toggle": "5.0.14",
34 34
     "@atlaskit/tooltip": "12.1.13",
35
-    "@jitsi/js-utils": "1.0.3",
35
+    "@jitsi/js-utils": "1.0.5",
36 36
     "@microsoft/microsoft-graph-client": "1.1.0",
37 37
     "@react-native-async-storage/async-storage": "1.13.2",
38 38
     "@react-native-community/google-signin": "3.0.1",

+ 2
- 1
react/features/base/jitsi-local-storage/setup.web.js View File

@@ -2,6 +2,7 @@
2 2
 
3 3
 import { jitsiLocalStorage } from '@jitsi/js-utils/jitsi-local-storage';
4 4
 
5
+import { browser } from '../lib-jitsi-meet';
5 6
 import { parseURLParams } from '../util/parseURLParams';
6 7
 
7 8
 import logger from './logger';
@@ -23,7 +24,7 @@ function onFakeLocalStorageChanged() {
23 24
  * @returns {void}
24 25
  */
25 26
 function setupJitsiLocalStorage() {
26
-    if (jitsiLocalStorage.isLocalStorageDisabled()) {
27
+    if (jitsiLocalStorage.isLocalStorageDisabled() || browser.isSafari()) {
27 28
         const urlParams = parseURLParams(window.location);
28 29
 
29 30
         try {

+ 0
- 5
react/features/billing-counter/actionTypes.js View File

@@ -1,8 +1,3 @@
1
-/**
2
- * Action used to store the billing id.
3
- */
4
-export const SET_BILLING_ID = 'SET_BILLING_ID';
5
-
6 1
 /**
7 2
  * Action used to store the flag signaling the endpoint has been counted.
8 3
  */

+ 2
- 23
react/features/billing-counter/actions.js View File

@@ -1,13 +1,10 @@
1 1
 // @flow
2 2
 
3
-import uuid from 'uuid';
4
-
5
-import { SET_BILLING_ID, SET_ENDPOINT_COUNTED } from './actionTypes';
3
+import { SET_ENDPOINT_COUNTED } from './actionTypes';
6 4
 import { extractVpaasTenantFromPath, getBillingId, sendCountRequest } from './functions';
7 5
 
8 6
 /**
9 7
  * Sends a billing count request when needed.
10
- * If there is no billingId, it presists one first and sends the request after.
11 8
  *
12 9
  * @returns {Function}
13 10
  */
@@ -20,12 +17,7 @@ export function countEndpoint() {
20 17
         const shouldSendRequest = Boolean(baseUrl && jwt && tenant);
21 18
 
22 19
         if (shouldSendRequest) {
23
-            let billingId = getBillingId();
24
-
25
-            if (!billingId) {
26
-                billingId = uuid.v4();
27
-                dispatch(setBillingId(billingId));
28
-            }
20
+            const billingId = getBillingId();
29 21
 
30 22
             sendCountRequest({
31 23
                 baseUrl,
@@ -38,19 +30,6 @@ export function countEndpoint() {
38 30
     };
39 31
 }
40 32
 
41
-/**
42
- * Action used to set the user billing id.
43
- *
44
- * @param {string} value - The uid.
45
- * @returns {Object}
46
- */
47
-function setBillingId(value) {
48
-    return {
49
-        type: SET_BILLING_ID,
50
-        value
51
-    };
52
-}
53
-
54 33
 /**
55 34
  * Action used to mark the endpoint as counted.
56 35
  *

+ 10
- 11
react/features/billing-counter/functions.js View File

@@ -1,6 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import { jitsiLocalStorage } from '@jitsi/js-utils';
4
+import uuid from 'uuid';
4 5
 
5 6
 import { BILLING_ID, VPAAS_TENANT_PREFIX } from './constants';
6 7
 import logger from './logger';
@@ -72,20 +73,18 @@ export async function sendCountRequest({ baseUrl, billingId, jwt, tenant }: {
72 73
 }
73 74
 
74 75
 /**
75
- * Returns the stored billing id.
76
+ * Returns the stored billing id (or generates a new one if none is present).
76 77
  *
77 78
  * @returns {string}
78 79
  */
79 80
 export function getBillingId() {
80
-    return jitsiLocalStorage.getItem(BILLING_ID);
81
-}
82 81
 
83
-/**
84
- * Stores the billing id.
85
- *
86
- * @param {string} value - The id to be stored.
87
- * @returns {void}
88
- */
89
-export function setBillingId(value: string) {
90
-    jitsiLocalStorage.setItem(BILLING_ID, value);
82
+    let billingId = jitsiLocalStorage.getItem(BILLING_ID);
83
+
84
+    if (!billingId) {
85
+        billingId = uuid.v4();
86
+        jitsiLocalStorage.setItem(BILLING_ID, billingId);
87
+    }
88
+
89
+    return billingId;
91 90
 }

+ 1
- 7
react/features/billing-counter/middleware.js View File

@@ -3,9 +3,8 @@ import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
3 3
 import { PARTICIPANT_JOINED } from '../base/participants/actionTypes';
4 4
 import { MiddlewareRegistry } from '../base/redux';
5 5
 
6
-import { SET_BILLING_ID } from './actionTypes';
7 6
 import { countEndpoint } from './actions';
8
-import { isVpaasMeeting, extractVpaasTenantFromPath, setBillingId } from './functions';
7
+import { isVpaasMeeting, extractVpaasTenantFromPath } from './functions';
9 8
 
10 9
 /**
11 10
  * The redux middleware for billing counter.
@@ -21,11 +20,6 @@ MiddlewareRegistry.register(store => next => async action => {
21 20
 
22 21
         break;
23 22
     }
24
-    case SET_BILLING_ID: {
25
-        setBillingId(action.value);
26
-
27
-        break;
28
-    }
29 23
 
30 24
     case PARTICIPANT_JOINED: {
31 25
         const shouldCount = !store.getState()['features/billing-counter'].endpointCounted

Loading…
Cancel
Save