@signiphi/page-assembly 0.2.0-beta.6 → 0.2.0-beta.8

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.
package/dist/index.mjs CHANGED
@@ -1987,8 +1987,9 @@ var PageAssembler = forwardRef(
1987
1987
  setProcessingStatus("");
1988
1988
  }
1989
1989
  }, []);
1990
+ const hasRestorableState = !!initialState && initialState.files.length > 0;
1990
1991
  useEffect(() => {
1991
- if (initialPdf && !initialState) {
1992
+ if (initialPdf && state.files.length === 0 && !hasRestorableState) {
1992
1993
  const pdfIdentifier = initialPdf instanceof Uint8Array ? `uint8array-${initialPdf.length}-${initialPdf[0]}-${initialPdf[initialPdf.length - 1]}` : `${initialPdf.constructor.name}-${initialPdf.size || initialPdf.byteLength}`;
1993
1994
  if (processedInitialPdfRef.current === pdfIdentifier) {
1994
1995
  return;
@@ -1996,9 +1997,9 @@ var PageAssembler = forwardRef(
1996
1997
  processedInitialPdfRef.current = pdfIdentifier;
1997
1998
  processInitialPdf(initialPdf);
1998
1999
  }
1999
- }, [initialPdf, initialState, processInitialPdf]);
2000
+ }, [initialPdf, state.files.length, hasRestorableState, processInitialPdf]);
2000
2001
  useEffect(() => {
2001
- if (initialState) {
2002
+ if (initialState && initialState.files.length > 0) {
2002
2003
  dispatch({ type: "RESET", payload: initialState });
2003
2004
  }
2004
2005
  }, [initialState]);