@etsoo/appscript 1.5.52 → 1.5.53

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.
@@ -103,9 +103,15 @@ class CoreApp {
103
103
  return this.storage.getData(this.fields.keepLogin) ?? false;
104
104
  }
105
105
  set keepLogin(value) {
106
+ const field = this.fields.headerToken;
106
107
  if (!value) {
107
108
  // Clear the token
108
109
  this.clearCacheToken();
110
+ // Remove the token field
111
+ this.persistedFields.remove(field);
112
+ }
113
+ else if (!this.persistedFields.includes(field)) {
114
+ this.persistedFields.push(field);
109
115
  }
110
116
  this.storage.setData(this.fields.keepLogin, value);
111
117
  }
@@ -132,7 +138,6 @@ class CoreApp {
132
138
  this.fields.deviceId,
133
139
  this.fields.devicePassphrase,
134
140
  this.fields.serversideDeviceId,
135
- this.fields.headerToken,
136
141
  this.fields.keepLogin
137
142
  ];
138
143
  }
@@ -336,19 +341,13 @@ class CoreApp {
336
341
  // Devices
337
342
  const devices = this.storage.getPersistedData(this.fields.devices);
338
343
  if (devices != null) {
339
- const index = devices.indexOf(this.getDeviceId());
340
- if (index !== -1) {
341
- // Remove current device from the list
342
- devices.splice(index, 1);
344
+ if (devices.remove(this.getDeviceId()).length > 0) {
343
345
  this.storage.setPersistedData(this.fields.devices, devices);
344
346
  }
345
347
  }
346
348
  if (!this.authorized)
347
349
  return;
348
- const fields = this.keepLogin
349
- ? this.persistedFields
350
- : this.persistedFields.filter((f) => f !== this.fields.headerToken);
351
- this.storage.copyTo(fields);
350
+ this.storage.copyTo(this.persistedFields);
352
351
  }
353
352
  /**
354
353
  * Add scheduled task
@@ -52,9 +52,7 @@ var BusinessUtils;
52
52
  }
53
53
  });
54
54
  // Remove the default culture
55
- const index = allCultures.findIndex((a) => a.id === cultures[0].id);
56
- if (index !== -1)
57
- allCultures.splice(index, 1);
55
+ allCultures.remove((a) => a.id === cultures[0].id);
58
56
  // Sort
59
57
  allCultures.sortByProperty('id', cultures.map((c) => c.id));
60
58
  // Set back
@@ -247,12 +247,7 @@ class ShoppingCart {
247
247
  }
248
248
  else {
249
249
  ShoppingCart.clear(this.identifier, this.storage);
250
- const keys = this.keys;
251
- const index = keys.indexOf(this.identifier);
252
- if (index !== -1) {
253
- keys.splice(index, 1);
254
- this.keys = keys;
255
- }
250
+ this.keys.remove(this.identifier);
256
251
  }
257
252
  this.doChange('clear', []);
258
253
  }
@@ -100,9 +100,15 @@ export class CoreApp {
100
100
  return this.storage.getData(this.fields.keepLogin) ?? false;
101
101
  }
102
102
  set keepLogin(value) {
103
+ const field = this.fields.headerToken;
103
104
  if (!value) {
104
105
  // Clear the token
105
106
  this.clearCacheToken();
107
+ // Remove the token field
108
+ this.persistedFields.remove(field);
109
+ }
110
+ else if (!this.persistedFields.includes(field)) {
111
+ this.persistedFields.push(field);
106
112
  }
107
113
  this.storage.setData(this.fields.keepLogin, value);
108
114
  }
@@ -129,7 +135,6 @@ export class CoreApp {
129
135
  this.fields.deviceId,
130
136
  this.fields.devicePassphrase,
131
137
  this.fields.serversideDeviceId,
132
- this.fields.headerToken,
133
138
  this.fields.keepLogin
134
139
  ];
135
140
  }
@@ -333,19 +338,13 @@ export class CoreApp {
333
338
  // Devices
334
339
  const devices = this.storage.getPersistedData(this.fields.devices);
335
340
  if (devices != null) {
336
- const index = devices.indexOf(this.getDeviceId());
337
- if (index !== -1) {
338
- // Remove current device from the list
339
- devices.splice(index, 1);
341
+ if (devices.remove(this.getDeviceId()).length > 0) {
340
342
  this.storage.setPersistedData(this.fields.devices, devices);
341
343
  }
342
344
  }
343
345
  if (!this.authorized)
344
346
  return;
345
- const fields = this.keepLogin
346
- ? this.persistedFields
347
- : this.persistedFields.filter((f) => f !== this.fields.headerToken);
348
- this.storage.copyTo(fields);
347
+ this.storage.copyTo(this.persistedFields);
349
348
  }
350
349
  /**
351
350
  * Add scheduled task
@@ -49,9 +49,7 @@ export var BusinessUtils;
49
49
  }
50
50
  });
51
51
  // Remove the default culture
52
- const index = allCultures.findIndex((a) => a.id === cultures[0].id);
53
- if (index !== -1)
54
- allCultures.splice(index, 1);
52
+ allCultures.remove((a) => a.id === cultures[0].id);
55
53
  // Sort
56
54
  allCultures.sortByProperty('id', cultures.map((c) => c.id));
57
55
  // Set back
@@ -244,12 +244,7 @@ export class ShoppingCart {
244
244
  }
245
245
  else {
246
246
  ShoppingCart.clear(this.identifier, this.storage);
247
- const keys = this.keys;
248
- const index = keys.indexOf(this.identifier);
249
- if (index !== -1) {
250
- keys.splice(index, 1);
251
- this.keys = keys;
252
- }
247
+ this.keys.remove(this.identifier);
253
248
  }
254
249
  this.doChange('clear', []);
255
250
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.52",
3
+ "version": "1.5.53",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -52,9 +52,9 @@
52
52
  },
53
53
  "homepage": "https://github.com/ETSOO/AppScript#readme",
54
54
  "dependencies": {
55
- "@etsoo/notificationbase": "^1.1.50",
56
- "@etsoo/restclient": "^1.1.12",
57
- "@etsoo/shared": "^1.2.49",
55
+ "@etsoo/notificationbase": "^1.1.52",
56
+ "@etsoo/restclient": "^1.1.14",
57
+ "@etsoo/shared": "^1.2.51",
58
58
  "crypto-js": "^4.2.0"
59
59
  },
60
60
  "devDependencies": {
@@ -256,9 +256,15 @@ export abstract class CoreApp<
256
256
  return this.storage.getData<boolean>(this.fields.keepLogin) ?? false;
257
257
  }
258
258
  set keepLogin(value: boolean) {
259
+ const field = this.fields.headerToken;
259
260
  if (!value) {
260
261
  // Clear the token
261
262
  this.clearCacheToken();
263
+
264
+ // Remove the token field
265
+ this.persistedFields.remove(field);
266
+ } else if (!this.persistedFields.includes(field)) {
267
+ this.persistedFields.push(field);
262
268
  }
263
269
  this.storage.setData(this.fields.keepLogin, value);
264
270
  }
@@ -311,7 +317,6 @@ export abstract class CoreApp<
311
317
  this.fields.deviceId,
312
318
  this.fields.devicePassphrase,
313
319
  this.fields.serversideDeviceId,
314
- this.fields.headerToken,
315
320
  this.fields.keepLogin
316
321
  ];
317
322
  }
@@ -566,21 +571,14 @@ export abstract class CoreApp<
566
571
  this.fields.devices
567
572
  );
568
573
  if (devices != null) {
569
- const index = devices.indexOf(this.getDeviceId());
570
- if (index !== -1) {
571
- // Remove current device from the list
572
- devices.splice(index, 1);
574
+ if (devices.remove(this.getDeviceId()).length > 0) {
573
575
  this.storage.setPersistedData(this.fields.devices, devices);
574
576
  }
575
577
  }
576
578
 
577
579
  if (!this.authorized) return;
578
580
 
579
- const fields = this.keepLogin
580
- ? this.persistedFields
581
- : this.persistedFields.filter((f) => f !== this.fields.headerToken);
582
-
583
- this.storage.copyTo(fields);
581
+ this.storage.copyTo(this.persistedFields);
584
582
  }
585
583
 
586
584
  /**
@@ -62,9 +62,7 @@ export namespace BusinessUtils {
62
62
  });
63
63
 
64
64
  // Remove the default culture
65
- const index = allCultures.findIndex((a) => a.id === cultures[0].id);
66
- if (index !== -1) allCultures.splice(index, 1);
67
-
65
+ allCultures.remove((a) => a.id === cultures[0].id);
68
66
  // Sort
69
67
  allCultures.sortByProperty(
70
68
  'id',
@@ -475,13 +475,7 @@ export class ShoppingCart<T extends ShoppingCartItem> {
475
475
  this.save();
476
476
  } else {
477
477
  ShoppingCart.clear(this.identifier, this.storage);
478
-
479
- const keys = this.keys;
480
- const index = keys.indexOf(this.identifier);
481
- if (index !== -1) {
482
- keys.splice(index, 1);
483
- this.keys = keys;
484
- }
478
+ this.keys.remove(this.identifier);
485
479
  }
486
480
 
487
481
  this.doChange('clear', []);