@subiz/widget-v4 4.1.21 → 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.21",
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)) {
@@ -374,8 +373,8 @@ export default class Store {
374
373
  async init(accid, mask, userRef) {
375
374
  this.readyGate.close()
376
375
  accid = (accid || '').trim()
377
- this.api.setAuth({accid: accid})
378
376
  this.g_sync = {}
377
+
379
378
  if (!userRef) {
380
379
  // try to find userRef in cookie
381
380
  try {
@@ -408,6 +407,11 @@ export default class Store {
408
407
  }
409
408
  }
410
409
 
410
+ if (this.cookie.get('__sbref', userRef) != userRef) {
411
+ cleanMyLocalStorage()
412
+ }
413
+
414
+ this.api.setAuth({accid: accid})
411
415
  // set cookie forever
412
416
  if (userRef) this.cookie.set('__sbref', userRef)
413
417
 
@@ -1274,3 +1278,24 @@ let cleanLocalStorage = () => {
1274
1278
  }
1275
1279
  })
1276
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