@subiz/widget-v4 4.1.20 → 4.1.24

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.
@@ -4345,9 +4345,6 @@ class Store {
4345
4345
  async init(accid, mask, userRef) {
4346
4346
  this.readyGate.close();
4347
4347
  accid = (accid || '').trim();
4348
- this.api.setAuth({
4349
- accid: accid
4350
- });
4351
4348
  this.g_sync = {};
4352
4349
  if (!userRef) {
4353
4350
  try {
@@ -4373,6 +4370,12 @@ class Store {
4373
4370
  }
4374
4371
  }
4375
4372
  }
4373
+ if (this.cookie.get('__sbref', userRef) != userRef) {
4374
+ cleanMyLocalStorage();
4375
+ }
4376
+ this.api.setAuth({
4377
+ accid: accid
4378
+ });
4376
4379
  if (userRef) this.cookie.set('__sbref', userRef);
4377
4380
  let user = await this.api.setAuth({
4378
4381
  accid: accid,
@@ -5080,6 +5083,20 @@ let cleanLocalStorage = () => {
5080
5083
  }
5081
5084
  });
5082
5085
  };
5086
+ let cleanMyLocalStorage = () => {
5087
+ try {
5088
+ localStorage;
5089
+ } catch (e) {
5090
+ return;
5091
+ }
5092
+ util/* default.setTimeout */.Z.setTimeout(() => {
5093
+ for (var key in localStorage) {
5094
+ if (key && (key.startsWith('cbz2020') || key.startsWith('sbz2020') || key.startsWith('sbz2022') || key.startsWith('sbz2023'))) {
5095
+ localStorage.removeItem(key);
5096
+ }
5097
+ }
5098
+ });
5099
+ };
5083
5100
  // EXTERNAL MODULE: ./src/common.js
5084
5101
  var common = __webpack_require__(2493);
5085
5102
  // EXTERNAL MODULE: ./node_modules/preact/dist/preact.module.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.20",
3
+ "version": "4.1.24",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -28,7 +28,16 @@ export default class {
28
28
  this.accid = obj.accid
29
29
  this.mask = obj.mask
30
30
  this.uid = obj.uid
31
- return {account_id: this.accid, id: 'usqzgtgfake'}
31
+ return {
32
+ account_id: this.accid,
33
+ id: 'usqzgtgfake',
34
+ attributes: [
35
+ {
36
+ key: 'fullname',
37
+ text: 'Kiều Thanh',
38
+ },
39
+ ],
40
+ }
32
41
  }
33
42
 
34
43
  listConversations = (_) => {
@@ -68,7 +77,19 @@ export default class {
68
77
  time = (_) => Promise.resolve({code: 200, body: new sb.Date().toISOString()})
69
78
  updateUser = (data) => OK200
70
79
 
71
- getUser = (_) => Promise.resolve({code: 200, body: {id: '-'}})
80
+ getUser = (_) =>
81
+ Promise.resolve({
82
+ code: 200,
83
+ body: {
84
+ id: 'usqzgtgfake',
85
+ attributes: [
86
+ {
87
+ key: 'fullname',
88
+ text: 'Kiều Thanh',
89
+ },
90
+ ],
91
+ },
92
+ })
72
93
  getAccountSetting = () => this.apireq.get(`/accounts/${this.accid}/settings`)
73
94
  getIsOnline = () => this.apireq.get(`/accounts/${this.accid}/is_online`)
74
95
 
@@ -290,7 +290,6 @@ export default class Store {
290
290
  list_districts = (p) => this.api.list_districts(p)
291
291
  list_wards = (p) => this.api.list_wards(p)
292
292
 
293
- list_provices
294
293
  listEvents = (id) => {
295
294
  if (!id || id === '*' || typeof id !== 'string') return
296
295
  if (!this.isInsync('events' + id)) {
@@ -375,6 +374,7 @@ export default class Store {
375
374
  this.readyGate.close()
376
375
  accid = (accid || '').trim()
377
376
  this.g_sync = {}
377
+
378
378
  if (!userRef) {
379
379
  // try to find userRef in cookie
380
380
  try {
@@ -407,10 +407,11 @@ export default class Store {
407
407
  }
408
408
  }
409
409
 
410
- this.api.setAuth({accid: accid})
411
-
412
- userRef = this.cookie.get('__sbref', '')
410
+ if (this.cookie.get('__sbref', userRef) != userRef) {
411
+ cleanMyLocalStorage()
412
+ }
413
413
 
414
+ this.api.setAuth({accid: accid})
414
415
  // set cookie forever
415
416
  if (userRef) this.cookie.set('__sbref', userRef)
416
417
 
@@ -1277,3 +1278,24 @@ let cleanLocalStorage = () => {
1277
1278
  }
1278
1279
  })
1279
1280
  }
1281
+
1282
+ let cleanMyLocalStorage = () => {
1283
+ try {
1284
+ localStorage
1285
+ } catch (e) {
1286
+ return
1287
+ }
1288
+ sb.setTimeout(() => {
1289
+ for (var key in localStorage) {
1290
+ if (
1291
+ key &&
1292
+ (key.startsWith('cbz2020') ||
1293
+ key.startsWith('sbz2020') ||
1294
+ key.startsWith('sbz2022') ||
1295
+ key.startsWith('sbz2023'))
1296
+ ) {
1297
+ localStorage.removeItem(key)
1298
+ }
1299
+ }
1300
+ })
1301
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes