Синхронизация и фикс двойного сокета

This commit is contained in:
RoyceDa
2026-02-08 18:14:32 +02:00
parent 44e8d685df
commit 350e10676c
4 changed files with 19 additions and 9 deletions

View File

@@ -437,16 +437,17 @@ export function useDialogFiber() {
return;
}
const fromPublicKey = packet.getFromPublicKey();
const toPublicKey = packet.getToPublicKey();
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 = ?`,
[toPublicKey, fromPublicKey, publicKey]);
[fromPublicKey, toPublicKey, publicKey]);
console.info("updating with params ", [fromPublicKey, toPublicKey, publicKey]);
updateDialog(toPublicKey);
log("Read sync packet from other device");
addOrUpdateDialogCache(fromPublicKey, getDialogCache(fromPublicKey).map((message) => {
@@ -460,7 +461,7 @@ export function useDialogFiber() {
}
return message;
}));
}, [updateDialog]);
}, [updateDialog, publicKey]);
/**
* Обработчик прочтения личных сообщений
@@ -475,6 +476,13 @@ export function useDialogFiber() {
}
const fromPublicKey = packet.getFromPublicKey();
const toPublicKey = packet.getToPublicKey();
if(fromPublicKey == publicKey){
/**
* Игнорируем если это наше прочтение
* которое получается при синхронизации
*/
return;
}
await runQuery(`UPDATE messages SET read = 1 WHERE from_public_key = ? AND to_public_key = ? AND account = ?`, [toPublicKey, fromPublicKey, publicKey]);
updateDialog(fromPublicKey);
log("Read packet received from " + fromPublicKey + " for " + toPublicKey);
@@ -489,7 +497,7 @@ export function useDialogFiber() {
}
return message;
}));
}, [updateDialog]);
}, [updateDialog, publicKey]);
/**
* Обработчик прочтения групповых сообщений
*/