@calimero-network/mero-react 3.0.0 → 3.0.1

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.cjs CHANGED
@@ -2187,7 +2187,9 @@ function useGroupUpgradeStatus(groupId) {
2187
2187
  const [loading, setLoading] = react.useState(false);
2188
2188
  const [error, setError] = react.useState(null);
2189
2189
  const mountedRef = useMountedRef();
2190
+ const reqRef = react.useRef(0);
2190
2191
  const refetch = react.useCallback(async () => {
2192
+ const seq = ++reqRef.current;
2191
2193
  if (!mero || !groupId) {
2192
2194
  if (mountedRef.current) {
2193
2195
  setUpgradeStatus(null);
@@ -2202,20 +2204,25 @@ function useGroupUpgradeStatus(groupId) {
2202
2204
  }
2203
2205
  try {
2204
2206
  const result = await mero.admin.getGroupUpgradeStatus(groupId);
2205
- if (mountedRef.current) {
2207
+ if (mountedRef.current && seq === reqRef.current) {
2206
2208
  setUpgradeStatus(result);
2207
2209
  }
2208
2210
  } catch (err) {
2209
2211
  const errorValue = toError(err);
2210
- if (mountedRef.current) {
2212
+ if (mountedRef.current && seq === reqRef.current) {
2211
2213
  setError(errorValue);
2212
2214
  }
2213
2215
  } finally {
2214
- if (mountedRef.current) {
2216
+ if (mountedRef.current && seq === reqRef.current) {
2215
2217
  setLoading(false);
2216
2218
  }
2217
2219
  }
2218
2220
  }, [groupId, mero, mountedRef]);
2221
+ react.useEffect(() => {
2222
+ reqRef.current += 1;
2223
+ setUpgradeStatus(null);
2224
+ setError(null);
2225
+ }, [groupId]);
2219
2226
  react.useEffect(() => {
2220
2227
  void refetch();
2221
2228
  }, [refetch]);
@@ -2500,6 +2507,11 @@ function useMyAuthoredMigration(contextId) {
2500
2507
  } catch {
2501
2508
  }
2502
2509
  }, [mero, contextId, mountedRef]);
2510
+ react.useEffect(() => {
2511
+ reqRef.current += 1;
2512
+ setPendingCount(0);
2513
+ setSummary(null);
2514
+ }, [contextId]);
2503
2515
  react.useEffect(() => {
2504
2516
  void refresh();
2505
2517
  }, [refresh]);