@aomi-labs/react 0.3.8 → 0.3.9
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/README.md +4 -4
- package/dist/index.cjs +19 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -882,6 +882,16 @@ import {
|
|
|
882
882
|
} from "react";
|
|
883
883
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
884
884
|
var UserContext = createContext5(void 0);
|
|
885
|
+
function normalizeUserState(next, data) {
|
|
886
|
+
if (data.isConnected === false) {
|
|
887
|
+
return __spreadProps(__spreadValues({}, next), {
|
|
888
|
+
address: void 0,
|
|
889
|
+
chainId: void 0,
|
|
890
|
+
ensName: void 0
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
return next;
|
|
894
|
+
}
|
|
885
895
|
function useUser() {
|
|
886
896
|
const context = useContext5(UserContext);
|
|
887
897
|
if (!context) {
|
|
@@ -911,7 +921,7 @@ function UserContextProvider({ children }) {
|
|
|
911
921
|
);
|
|
912
922
|
const setUser = useCallback4((data) => {
|
|
913
923
|
setUserState((prev) => {
|
|
914
|
-
const next = __spreadValues(__spreadValues({}, prev), data);
|
|
924
|
+
const next = normalizeUserState(__spreadValues(__spreadValues({}, prev), data), data);
|
|
915
925
|
StateChangeCallbacks.current.forEach((callback) => {
|
|
916
926
|
callback(next);
|
|
917
927
|
});
|
|
@@ -1508,7 +1518,11 @@ function AomiRuntimeCore({
|
|
|
1508
1518
|
cancelGeneration: orchestratorCancel,
|
|
1509
1519
|
aomiClientRef
|
|
1510
1520
|
} = useRuntimeOrchestrator(aomiClient, {
|
|
1511
|
-
getPublicKey: () =>
|
|
1521
|
+
getPublicKey: () => {
|
|
1522
|
+
var _a;
|
|
1523
|
+
const userState = getUserState();
|
|
1524
|
+
return userState.isConnected ? (_a = userState.address) != null ? _a : void 0 : void 0;
|
|
1525
|
+
},
|
|
1512
1526
|
getUserState,
|
|
1513
1527
|
getApp: getCurrentThreadApp,
|
|
1514
1528
|
getApiKey: () => getControlState().apiKey,
|
|
@@ -1591,7 +1605,7 @@ function AomiRuntimeCore({
|
|
|
1591
1605
|
threadContext.currentThreadId
|
|
1592
1606
|
);
|
|
1593
1607
|
useEffect3(() => {
|
|
1594
|
-
const userAddress = user.address;
|
|
1608
|
+
const userAddress = user.isConnected ? user.address : void 0;
|
|
1595
1609
|
if (!userAddress) return;
|
|
1596
1610
|
const fetchThreadList = async () => {
|
|
1597
1611
|
var _a, _b, _c;
|
|
@@ -1628,7 +1642,7 @@ function AomiRuntimeCore({
|
|
|
1628
1642
|
}
|
|
1629
1643
|
};
|
|
1630
1644
|
void fetchThreadList();
|
|
1631
|
-
}, [user.address, aomiClientRef]);
|
|
1645
|
+
}, [user.address, user.isConnected, aomiClientRef]);
|
|
1632
1646
|
const threadListAdapter = useMemo2(
|
|
1633
1647
|
() => buildThreadListAdapter({
|
|
1634
1648
|
aomiClientRef,
|
|
@@ -1831,7 +1845,7 @@ function AomiRuntimeInner({
|
|
|
1831
1845
|
{
|
|
1832
1846
|
aomiClient,
|
|
1833
1847
|
sessionId: threadContext.currentThreadId,
|
|
1834
|
-
publicKey: (_a = user.address) != null ? _a : void 0,
|
|
1848
|
+
publicKey: user.isConnected ? (_a = user.address) != null ? _a : void 0 : void 0,
|
|
1835
1849
|
getThreadMetadata: threadContext.getThreadMetadata,
|
|
1836
1850
|
updateThreadMetadata: threadContext.updateThreadMetadata,
|
|
1837
1851
|
children: /* @__PURE__ */ jsx7(
|