@verdocs/web-sdk 6.5.0-beta.23 → 6.5.0-beta.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.
@@ -918,18 +918,33 @@ const VerdocsSign = class {
918
918
  filledFields: recipientFields.filter(f => isFilled(f)).map(f => ({ name: f.name, type: f.type, val: f.value })),
919
919
  });
920
920
  let mode = 'start';
921
- // We only consider the user to have started "signing" if they have filled out at least one *fillable* field.
922
- // Readonly fields do not count.
923
- const anyFieldFilled = requiredRemaining < requiredFields.length || optionalRemaining < optionalFields.length;
921
+ // We need a way to know if the user has started signing. But after trying two
922
+ // obvious ways (has the user adopted a signature? are any fields filled in yet?)
923
+ // they both had flaws (we could be carrying over a sig from a previous session,
924
+ // and things like defaults and auto-filled fields make the filled-field approach
925
+ // tricky to maintain).
926
+ // This is sort of a Hail Mary but it works well for now. We just keep a variable
927
+ // in localStorage that tracks the last 10 envelopes the user has "started".
928
+ // We never get a chance to clean them up but 10 GUIDs is tiny compared to what
929
+ // many apps store in a user's browser.
930
+ const startedEnvelopes = JSON.parse(localStorage.getItem('startedEnvelopes') || '[]');
931
+ const hasStarted = startedEnvelopes.includes(this.envelopeId);
924
932
  if (this.nextSubmits) {
925
933
  mode = 'completed';
926
934
  }
927
- else if (anyFieldFilled) {
935
+ else if (hasStarted) {
928
936
  mode = 'signing';
929
937
  }
930
938
  return (index.h("verdocs-signing-progress", { mode: mode, current: Math.max(1, currentIndex), total: totalFields, remainingFields: remainingFields, progress: progress, fieldLabel: getFieldLabel(focusedFieldObj), fieldCompleted: focusedFieldObj ? !!isFilled(focusedFieldObj) : false, onStarted: () => {
931
939
  this.adoptingSignature = true;
932
- // this.handleNext();
940
+ const startedEnvelopes = JSON.parse(localStorage.getItem('startedEnvelopes') || '[]');
941
+ if (!startedEnvelopes.includes(this.envelopeId)) {
942
+ startedEnvelopes.push(this.envelopeId);
943
+ while (startedEnvelopes.length > 10) {
944
+ startedEnvelopes.shift();
945
+ }
946
+ localStorage.setItem('startedEnvelopes', JSON.stringify(startedEnvelopes));
947
+ }
933
948
  }, onNext: () => this.handleNext(), onPrevious: () => this.handlePrev(), onExit: () => this.handleNext() }));
934
949
  })(), index.h("div", { class: `document signed-document-container zoom-${this.zoomLevel}` }, (this.envelope.documents || []).map(envelopeDocument => {
935
950
  const pageNumbers = jsSdk.integerSequence(1, envelopeDocument.pages);