fix and update

This commit is contained in:
lendry
2026-07-01 00:06:36 +03:00
parent deb213bd77
commit a0c1722a8d
6 changed files with 188 additions and 17 deletions

View File

@@ -11,6 +11,8 @@ import {
type E2EMessagePayload
} from '@/lib/e2e-chat';
const publishedE2EKeys = new Set<string>();
export function resolveChatPeerUserId(room: ChatRoom | null | undefined, userId: string | undefined) {
if (!room || !userId) return null;
const fromMembers = room.members.find((member) => member.userId !== userId)?.userId;
@@ -69,7 +71,10 @@ export function useE2EChat(options: {
void (async () => {
try {
const { publicKey } = await ensureE2EKeyPair(options.userId!);
const cacheKey = `${options.userId}:${publicKey}`;
if (publishedE2EKeys.has(cacheKey)) return;
await setUserE2EPublicKey(options.userId!, publicKey, options.token);
publishedE2EKeys.add(cacheKey);
} catch {
// фоновая инициализация E2E
}