@calimero-network/mero-react 2.6.0 → 3.0.0
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 +45 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +45 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2107,39 +2107,42 @@ function useMemberMetadata(groupId, identity) {
|
|
|
2107
2107
|
const [metadata, setMetadata] = react.useState(null);
|
|
2108
2108
|
const [loading, setLoading] = react.useState(false);
|
|
2109
2109
|
const [error, setError] = react.useState(null);
|
|
2110
|
-
const
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
}
|
|
2120
|
-
if (mountedRef.current) {
|
|
2121
|
-
setLoading(true);
|
|
2122
|
-
setError(null);
|
|
2123
|
-
}
|
|
2124
|
-
try {
|
|
2125
|
-
const result = await mero.admin.getMemberMetadata(groupId, identity);
|
|
2126
|
-
if (mountedRef.current) {
|
|
2127
|
-
setMetadata(result);
|
|
2110
|
+
const run = react.useCallback(
|
|
2111
|
+
async (signal) => {
|
|
2112
|
+
if (!mero || !groupId || !identity) {
|
|
2113
|
+
if (!signal.aborted) {
|
|
2114
|
+
setMetadata(null);
|
|
2115
|
+
setError(null);
|
|
2116
|
+
setLoading(false);
|
|
2117
|
+
}
|
|
2118
|
+
return;
|
|
2128
2119
|
}
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
setError(errorValue);
|
|
2120
|
+
if (!signal.aborted) {
|
|
2121
|
+
setLoading(true);
|
|
2122
|
+
setError(null);
|
|
2133
2123
|
}
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2124
|
+
try {
|
|
2125
|
+
const result = await mero.admin.getMemberMetadata(groupId, identity);
|
|
2126
|
+
if (!signal.aborted) setMetadata(result);
|
|
2127
|
+
} catch (err) {
|
|
2128
|
+
if (!signal.aborted) setError(toError(err));
|
|
2129
|
+
} finally {
|
|
2130
|
+
if (!signal.aborted) setLoading(false);
|
|
2137
2131
|
}
|
|
2138
|
-
}
|
|
2139
|
-
|
|
2132
|
+
},
|
|
2133
|
+
[mero, groupId, identity]
|
|
2134
|
+
);
|
|
2140
2135
|
react.useEffect(() => {
|
|
2141
|
-
|
|
2142
|
-
|
|
2136
|
+
const signal = { aborted: false };
|
|
2137
|
+
void run(signal);
|
|
2138
|
+
return () => {
|
|
2139
|
+
signal.aborted = true;
|
|
2140
|
+
};
|
|
2141
|
+
}, [run]);
|
|
2142
|
+
const refetch = react.useCallback(async () => {
|
|
2143
|
+
const signal = { aborted: false };
|
|
2144
|
+
await run(signal);
|
|
2145
|
+
}, [run]);
|
|
2143
2146
|
return { metadata, loading, error, refetch };
|
|
2144
2147
|
}
|
|
2145
2148
|
function useRegisterGroupSigningKey() {
|
|
@@ -2166,6 +2169,18 @@ function useUpgradeGroup() {
|
|
|
2166
2169
|
);
|
|
2167
2170
|
return { upgradeGroup, loading, error };
|
|
2168
2171
|
}
|
|
2172
|
+
function useResyncContext() {
|
|
2173
|
+
const { mero } = useMero();
|
|
2174
|
+
const { loading, error, run } = useAsyncMutation();
|
|
2175
|
+
const resyncContext = react.useCallback(
|
|
2176
|
+
async (contextId, request = {}) => {
|
|
2177
|
+
if (!mero) return null;
|
|
2178
|
+
return run(() => mero.admin.resyncContext(contextId, request));
|
|
2179
|
+
},
|
|
2180
|
+
[mero, run]
|
|
2181
|
+
);
|
|
2182
|
+
return { resyncContext, loading, error };
|
|
2183
|
+
}
|
|
2169
2184
|
function useGroupUpgradeStatus(groupId) {
|
|
2170
2185
|
const { mero } = useMero();
|
|
2171
2186
|
const [upgradeStatus, setUpgradeStatus] = react.useState(null);
|
|
@@ -2686,6 +2701,7 @@ exports.useNamespacesForApplication = useNamespacesForApplication;
|
|
|
2686
2701
|
exports.useNestGroup = useNestGroup;
|
|
2687
2702
|
exports.useRegisterGroupSigningKey = useRegisterGroupSigningKey;
|
|
2688
2703
|
exports.useRemoveGroupMembers = useRemoveGroupMembers;
|
|
2704
|
+
exports.useResyncContext = useResyncContext;
|
|
2689
2705
|
exports.useRetryGroupUpgrade = useRetryGroupUpgrade;
|
|
2690
2706
|
exports.useSetContextMetadata = useSetContextMetadata;
|
|
2691
2707
|
exports.useSetDefaultCapabilities = useSetDefaultCapabilities;
|