@salesforce/lds-drafts 1.114.1 → 1.114.2

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.
Files changed (2) hide show
  1. package/dist/ldsDrafts.js +35 -20
  2. package/package.json +2 -2
package/dist/ldsDrafts.js CHANGED
@@ -712,16 +712,24 @@ class DurableDraftQueue {
712
712
  await this.startQueueSafe();
713
713
  return Promise.reject('No action to replace');
714
714
  }
715
- const { actionToReplace, replacingAction } = this.getHandler(first.handler).handleReplaceAction(actionId, withActionId, this.uploadingActionId, actions);
716
- // TODO [W-8873834]: Will add batching support to durable store
717
- // we should use that here to remove and set both actions in one operation
718
- await this.removeDraftAction(replacingAction.id);
719
- await this.draftStore.writeAction(actionToReplace);
720
- await this.notifyChangedListeners({
721
- type: DraftQueueEventType.ActionUpdated,
722
- action: actionToReplace,
723
- });
724
- this.replacingAction = undefined;
715
+ // put in a try/finally block so we don't leave this.replacingAction
716
+ // indefinitely set
717
+ let actionToReplace;
718
+ try {
719
+ const replaceResult = this.getHandler(first.handler).handleReplaceAction(actionId, withActionId, this.uploadingActionId, actions);
720
+ actionToReplace = replaceResult.actionToReplace;
721
+ // TODO [W-8873834]: Will add batching support to durable store
722
+ // we should use that here to remove and set both actions in one operation
723
+ await this.removeDraftAction(replaceResult.replacingAction.id);
724
+ await this.draftStore.writeAction(actionToReplace);
725
+ await this.notifyChangedListeners({
726
+ type: DraftQueueEventType.ActionUpdated,
727
+ action: actionToReplace,
728
+ });
729
+ }
730
+ finally {
731
+ this.replacingAction = undefined;
732
+ }
725
733
  await this.startQueueSafe();
726
734
  return actionToReplace;
727
735
  });
@@ -751,16 +759,23 @@ class DurableDraftQueue {
751
759
  await this.startQueueSafe();
752
760
  throw Error('No action to replace');
753
761
  }
754
- const merged = this.getHandler(target.handler).mergeActions(target, source);
755
- // update the target
756
- await this.draftStore.writeAction(merged);
757
- await this.notifyChangedListeners({
758
- type: DraftQueueEventType.ActionUpdated,
759
- action: merged,
760
- });
761
- // remove the source from queue
762
- await this.removeDraftAction(sourceActionId);
763
- this.replacingAction = undefined;
762
+ // put in a try/finally block so we don't leave this.replacingAction
763
+ // indefinitely set
764
+ let merged;
765
+ try {
766
+ merged = this.getHandler(target.handler).mergeActions(target, source);
767
+ // update the target
768
+ await this.draftStore.writeAction(merged);
769
+ await this.notifyChangedListeners({
770
+ type: DraftQueueEventType.ActionUpdated,
771
+ action: merged,
772
+ });
773
+ // remove the source from queue
774
+ await this.removeDraftAction(sourceActionId);
775
+ }
776
+ finally {
777
+ this.replacingAction = undefined;
778
+ }
764
779
  await this.startQueueSafe();
765
780
  return merged;
766
781
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-drafts",
3
- "version": "1.114.1",
3
+ "version": "1.114.2",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS Drafts",
6
6
  "main": "dist/ldsDrafts.js",
@@ -26,6 +26,6 @@
26
26
  "dependencies": {
27
27
  "@luvio/engine": "0.137.1",
28
28
  "@luvio/environments": "0.137.1",
29
- "@salesforce/lds-utils-adapters": "^1.114.1"
29
+ "@salesforce/lds-utils-adapters": "^1.114.2"
30
30
  }
31
31
  }