fix and update
This commit is contained in:
@@ -52,7 +52,7 @@ export function useE2EChat(options: {
|
||||
userId?: string;
|
||||
token?: string | null;
|
||||
}) {
|
||||
const { isLoading } = useAuth();
|
||||
const { isLoading, isApiReady } = useAuth();
|
||||
const isE2E = options.room?.type === 'E2E';
|
||||
const peerUserId = useMemo(
|
||||
() => resolveChatPeerUserId(options.room, options.userId),
|
||||
@@ -65,7 +65,7 @@ export function useE2EChat(options: {
|
||||
const [e2eErrors, setE2eErrors] = useState<Record<string, string>>({});
|
||||
|
||||
useEffect(() => {
|
||||
if (!options.userId || !options.token || isLoading) return;
|
||||
if (!options.userId || !options.token || isLoading || !isApiReady) return;
|
||||
void (async () => {
|
||||
try {
|
||||
const { publicKey } = await ensureE2EKeyPair(options.userId!);
|
||||
@@ -74,7 +74,7 @@ export function useE2EChat(options: {
|
||||
// фоновая инициализация E2E
|
||||
}
|
||||
})();
|
||||
}, [isLoading, options.token, options.userId]);
|
||||
}, [isApiReady, isLoading, options.token, options.userId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isE2E || !peerUserId || !options.token) {
|
||||
|
||||
Reference in New Issue
Block a user