From 012a561471f14aaa3d0016253999a9adcaa04044 Mon Sep 17 00:00:00 2001 From: RoyceDa Date: Sun, 1 Feb 2026 01:07:29 +0200 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B8=D0=BD=D1=85=D1=80=D0=BE=D0=BD?= =?UTF-8?q?=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D1=87=D1=82=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BB=D0=B8=D1=87=D0=BD=D1=8B=D1=85=20=D1=81?= =?UTF-8?q?=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DialogProvider/useDialogFiber.ts | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/app/providers/DialogProvider/useDialogFiber.ts b/app/providers/DialogProvider/useDialogFiber.ts index 8daa29a..de5a59f 100644 --- a/app/providers/DialogProvider/useDialogFiber.ts +++ b/app/providers/DialogProvider/useDialogFiber.ts @@ -425,6 +425,43 @@ export function useDialogFiber() { } }, [blocked, muted, updateDialog, focused, currentDialogPublicKeyView, viewState, idle]); + /** + * Обработчик синхронизации прочтения личных сообщений + */ + usePacket(0x07, async (packet: PacketRead) => { + if(hasGroup(packet.getToPublicKey())){ + /** + * Если это относится к группам, то игнорируем здесь, + * для этого есть отдельный слушатель usePacket ниже + */ + return; + } + const fromPublicKey = packet.getFromPublicKey(); + if(fromPublicKey != publicKey){ + /** + * Игнорируем если это не наше прочтение + */ + return; + } + + const toPublicKey = packet.getToPublicKey(); + await runQuery(`UPDATE messages SET read = 1 WHERE from_public_key = ? AND to_public_key = ? AND account = ?`, + [fromPublicKey, toPublicKey, publicKey]); + updateDialog(toPublicKey); + log("Read sync packet from other device"); + addOrUpdateDialogCache(fromPublicKey, getDialogCache(fromPublicKey).map((message) => { + if (message.from_public_key == toPublicKey && !message.readed) { + console.info("Marking message as read in cache for dialog with " + fromPublicKey); + console.info({fromPublicKey, toPublicKey}); + return { + ...message, + readed: 1 + } + } + return message; + })); + }, [updateDialog]); + /** * Обработчик прочтения личных сообщений */