cogsbox-state 0.5.401 → 0.5.402

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-state",
3
- "version": "0.5.401",
3
+ "version": "0.5.402",
4
4
  "description": "React state management library with form controls and server sync",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/CogsState.tsx CHANGED
@@ -1976,7 +1976,11 @@ function createProxyHandler<T>(
1976
1976
  endIndex: totalCount,
1977
1977
  });
1978
1978
 
1979
+ let attemptCount = 0;
1980
+ const maxAttempts = 50;
1981
+
1979
1982
  intervalId = setInterval(() => {
1983
+ attemptCount++;
1980
1984
  const lastItemIndex = totalCount - 1;
1981
1985
  const shadowArray =
1982
1986
  getGlobalStore
@@ -1984,21 +1988,24 @@ function createProxyHandler<T>(
1984
1988
  .getShadowMetadata(stateKey, path) || [];
1985
1989
  const lastItemHeight =
1986
1990
  shadowArray[lastItemIndex]?.virtualizer?.itemHeight || 0;
1991
+
1987
1992
  console.log(
1988
- "ACTION (GETTING_HEIGHTS): lastItemHeight =",
1989
- lastItemHeight,
1990
- " index =",
1991
- lastItemIndex
1993
+ `ACTION (GETTING_HEIGHTS): attempt ${attemptCount}, lastItemHeight =`,
1994
+ lastItemHeight
1992
1995
  );
1996
+
1993
1997
  if (lastItemHeight > 0) {
1994
1998
  clearInterval(intervalId);
1995
- if (!shouldNotScroll.current) {
1996
- console.log(
1997
- "ACTION (GETTING_HEIGHTS): Measurement success -> SCROLLING_TO_BOTTOM"
1998
- );
1999
-
2000
- setStatus("SCROLLING_TO_BOTTOM");
2001
- }
1999
+ console.log(
2000
+ "ACTION (GETTING_HEIGHTS): Measurement success -> SCROLLING_TO_BOTTOM"
2001
+ );
2002
+ setStatus("SCROLLING_TO_BOTTOM");
2003
+ } else if (attemptCount >= maxAttempts) {
2004
+ clearInterval(intervalId);
2005
+ console.log(
2006
+ "ACTION (GETTING_HEIGHTS): Timeout - proceeding anyway"
2007
+ );
2008
+ setStatus("SCROLLING_TO_BOTTOM");
2002
2009
  }
2003
2010
  }, 100);
2004
2011
  } else if (status === "SCROLLING_TO_BOTTOM") {