@ai-matrx/media 0.5.1 → 0.5.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.
- package/CHANGELOG.md +13 -0
- package/dist/react.cjs +8 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +8 -0
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -628,13 +628,18 @@ function useMediaBlobLoadRecovery(ref, source, options) {
|
|
|
628
628
|
const refKey = stableRefKey(ref);
|
|
629
629
|
const [failed, setFailed] = useState2(false);
|
|
630
630
|
const attemptRef = useRef2(0);
|
|
631
|
+
const generationRef = useRef2(0);
|
|
631
632
|
const recoveryInFlightRef = useRef2(false);
|
|
632
633
|
const onRetry = options.onRetry;
|
|
633
634
|
const onTerminal = options.onTerminal;
|
|
634
635
|
useEffect2(() => {
|
|
636
|
+
generationRef.current += 1;
|
|
635
637
|
attemptRef.current = 0;
|
|
636
638
|
recoveryInFlightRef.current = false;
|
|
637
639
|
setFailed(false);
|
|
640
|
+
return () => {
|
|
641
|
+
generationRef.current += 1;
|
|
642
|
+
};
|
|
638
643
|
}, [refKey]);
|
|
639
644
|
useEffect2(() => {
|
|
640
645
|
recoveryInFlightRef.current = false;
|
|
@@ -659,6 +664,7 @@ function useMediaBlobLoadRecovery(ref, source, options) {
|
|
|
659
664
|
recoveryInFlightRef.current = true;
|
|
660
665
|
attemptRef.current += 1;
|
|
661
666
|
const attempt = attemptRef.current;
|
|
667
|
+
const generation = generationRef.current;
|
|
662
668
|
const recover = client.recoverBlobLoadError;
|
|
663
669
|
if (!ref || !recover) {
|
|
664
670
|
finishTerminal(
|
|
@@ -670,6 +676,7 @@ function useMediaBlobLoadRecovery(ref, source, options) {
|
|
|
670
676
|
}
|
|
671
677
|
recover(ref, attempt).then(
|
|
672
678
|
(verdict) => {
|
|
679
|
+
if (generation !== generationRef.current) return;
|
|
673
680
|
if (verdict === "retry") {
|
|
674
681
|
setFailed(false);
|
|
675
682
|
onRetry();
|
|
@@ -682,6 +689,7 @@ function useMediaBlobLoadRecovery(ref, source, options) {
|
|
|
682
689
|
);
|
|
683
690
|
},
|
|
684
691
|
(err) => {
|
|
692
|
+
if (generation !== generationRef.current) return;
|
|
685
693
|
finishTerminal(
|
|
686
694
|
event,
|
|
687
695
|
attempt,
|