cogsbox-state 0.5.400 → 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.400",
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
@@ -1985,15 +1989,23 @@ function createProxyHandler<T>(
1985
1989
  const lastItemHeight =
1986
1990
  shadowArray[lastItemIndex]?.virtualizer?.itemHeight || 0;
1987
1991
 
1992
+ console.log(
1993
+ `ACTION (GETTING_HEIGHTS): attempt ${attemptCount}, lastItemHeight =`,
1994
+ lastItemHeight
1995
+ );
1996
+
1988
1997
  if (lastItemHeight > 0) {
1989
1998
  clearInterval(intervalId);
1990
- if (!shouldNotScroll.current) {
1991
- console.log(
1992
- "ACTION (GETTING_HEIGHTS): Measurement success -> SCROLLING_TO_BOTTOM"
1993
- );
1994
-
1995
- setStatus("SCROLLING_TO_BOTTOM");
1996
- }
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");
1997
2009
  }
1998
2010
  }, 100);
1999
2011
  } else if (status === "SCROLLING_TO_BOTTOM") {