wacom 19.0.6 → 19.0.7

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.
@@ -1327,7 +1327,7 @@ class CrudService extends BaseService {
1327
1327
  new(doc = {}) {
1328
1328
  return {
1329
1329
  ...doc,
1330
- _id: Date.now().toString(),
1330
+ _id: doc._id || Date.now().toString(),
1331
1331
  __created: false,
1332
1332
  __modified: false,
1333
1333
  };
@@ -1339,7 +1339,21 @@ class CrudService extends BaseService {
1339
1339
  * @returns The found document or a new document if not found.
1340
1340
  */
1341
1341
  doc(_id) {
1342
- return this._docs.find((d) => this._id(d) === _id) || this.new();
1342
+ const doc = this._docs.find((d) => this._id(d) === _id) ||
1343
+ this.new({
1344
+ _id,
1345
+ });
1346
+ if (!this._docs.find((d) => this._id(d) === _id) &&
1347
+ !this._fetchingId[_id]) {
1348
+ this._fetchingId[_id] = true;
1349
+ setTimeout(() => {
1350
+ this.fetch({ _id }).subscribe((_doc) => {
1351
+ this._fetchingId[_id] = false;
1352
+ this._core.copy(_doc, doc);
1353
+ });
1354
+ });
1355
+ }
1356
+ return doc;
1343
1357
  }
1344
1358
  /**
1345
1359
  * Sets the number of documents to display per page.
@@ -1394,7 +1408,7 @@ class CrudService extends BaseService {
1394
1408
  if (doc.__created) {
1395
1409
  // Emit an error observable if the document is already created
1396
1410
  return new Observable((observer) => {
1397
- observer.error(new Error("Document has already been created."));
1411
+ observer.error(new Error('Document has already been created.'));
1398
1412
  });
1399
1413
  }
1400
1414
  doc.__created = true;
@@ -1702,6 +1716,7 @@ class CrudService extends BaseService {
1702
1716
  }
1703
1717
  this._core.complete(this._config.name + 'Loaded');
1704
1718
  }
1719
+ _fetchingId = {};
1705
1720
  }
1706
1721
 
1707
1722
  class StoreService {