fix and update

This commit is contained in:
lendry
2026-06-30 09:39:35 +03:00
parent 250976ca08
commit 4e98f6bfab
8 changed files with 192 additions and 110 deletions

View File

@@ -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) {