git
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
joinUserRoom,
|
||||
releaseChatSocket,
|
||||
} from "@/lib/chat/socketClient";
|
||||
import { ensureIdentityKeys } from "@/lib/e2ee";
|
||||
import E2eeIdentityGate from "@/components/chat/E2eeIdentityGate";
|
||||
|
||||
export default function ChatSocketProvider({
|
||||
children,
|
||||
@@ -15,14 +15,12 @@ export default function ChatSocketProvider({
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const user = useUser();
|
||||
const uid = user?._id ? String(user._id) : "";
|
||||
|
||||
useEffect(() => {
|
||||
if (!user?._id) return;
|
||||
if (!uid) return;
|
||||
|
||||
const socket = acquireChatSocket();
|
||||
const uid = String(user._id);
|
||||
|
||||
void ensureIdentityKeys(uid);
|
||||
|
||||
const join = () => joinUserRoom(uid);
|
||||
socket.on("connect", join);
|
||||
@@ -32,7 +30,15 @@ export default function ChatSocketProvider({
|
||||
socket.off("connect", join);
|
||||
releaseChatSocket();
|
||||
};
|
||||
}, [user?._id]);
|
||||
}, [uid]);
|
||||
|
||||
return children;
|
||||
return (
|
||||
<>
|
||||
{/* ensureIdentityKeys اینجا (تویِ خودِ گیت) صدا زده میشه، نه اینجا مستقیم —
|
||||
تا اگه هویتِ قبلی روی سرور هست و این دستگاه بهش دسترسی نداره، بهجای
|
||||
fail شدنِ بیصدا، از کاربر بازیابی/تاییدِ صریح خواسته بشه */}
|
||||
{uid ? <E2eeIdentityGate userId={uid} /> : null}
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user