Тестовая синхронизация

This commit is contained in:
RoyceDa
2026-02-13 17:13:21 +02:00
parent 3af1e53a19
commit 6a76061399
2 changed files with 31 additions and 12 deletions

View File

@@ -444,8 +444,10 @@ export function useDialogFiber() {
*/
return;
}
console.info("PACKED_READ_SYNC");
debugger;
await runQuery(`UPDATE messages SET read = 1 WHERE from_public_key = ? AND to_public_key = ? AND account = ?`,
[fromPublicKey, toPublicKey, publicKey]);
[toPublicKey, fromPublicKey, publicKey]);
console.info("updating with params ", [fromPublicKey, toPublicKey, publicKey]);
updateDialog(toPublicKey);
@@ -483,6 +485,7 @@ export function useDialogFiber() {
*/
return;
}
console.info("PACKED_READ_IM");
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);

View File

@@ -45,8 +45,7 @@ export function ProtocolProvider(props : ProtocolProviderProps) {
deviceOs: systemInfo.os
}
protocol.connect();
//protocol.startHandshakeExchange(publicKey, privateKey, device);
protocol.on('connect', () => {
const connect = () => {
console.info("Connected to server, starting handshake exchange");
protocol.startHandshakeExchange(publicKey, privateKey, device);
/**
@@ -54,24 +53,41 @@ export function ProtocolProvider(props : ProtocolProviderProps) {
* так как при переподключении они слетают
*/
setOnlineSubscribes([]);
});
protocol.on('reconnect', () => {
}
const reconnect = () => {
log("Connection lost, reconnecting and starting handshake exchange");
setConnect(ProtocolState.RECONNECTING);
});
protocol.on('handshake_start', () => {
}
const handshake_start = () => {
log("Handshake exchange started");
setConnect(ProtocolState.HANDSHAKE_EXCHANGE);
});
protocol.on('handshake_complete', () => {
}
const handshake_complete = () => {
log("Handshake exchange complete");
setConnect(ProtocolState.CONNECTED);
});
protocol.on('handshake_need_device_verification', () => {
}
const handshake_need_device_verification = () => {
log("Handshake exchange needs device verification");
setConnect(ProtocolState.DEVICE_VERIFICATION_REQUIRED);
navigate('/deviceconfirm');
});
}
protocol.on('connect', connect);
protocol.on('reconnect', reconnect);
protocol.on('handshake_start', handshake_start);
protocol.on('handshake_complete', handshake_complete);
protocol.on('handshake_need_device_verification', handshake_need_device_verification);
return () => {
/**
* Отключаем все обработчики событий при размонтировании компонента, чтобы избежать
* утечек памяти и некорректного поведения при повторном монтировании
*/
protocol.off('connect', connect);
protocol.off('reconnect', reconnect);
protocol.off('handshake_start', handshake_start);
protocol.off('handshake_complete', handshake_complete);
protocol.off('handshake_need_device_verification', handshake_need_device_verification);
}
}, [publicKey, privateKey, systemInfo.id]);
return (