Тестовая синхронизация
This commit is contained in:
@@ -444,8 +444,10 @@ export function useDialogFiber() {
|
|||||||
*/
|
*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.info("PACKED_READ_SYNC");
|
||||||
|
debugger;
|
||||||
await runQuery(`UPDATE messages SET read = 1 WHERE from_public_key = ? AND to_public_key = ? AND account = ?`,
|
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]);
|
console.info("updating with params ", [fromPublicKey, toPublicKey, publicKey]);
|
||||||
updateDialog(toPublicKey);
|
updateDialog(toPublicKey);
|
||||||
@@ -483,6 +485,7 @@ export function useDialogFiber() {
|
|||||||
*/
|
*/
|
||||||
return;
|
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]);
|
await runQuery(`UPDATE messages SET read = 1 WHERE from_public_key = ? AND to_public_key = ? AND account = ?`, [toPublicKey, fromPublicKey, publicKey]);
|
||||||
updateDialog(fromPublicKey);
|
updateDialog(fromPublicKey);
|
||||||
log("Read packet received from " + fromPublicKey + " for " + toPublicKey);
|
log("Read packet received from " + fromPublicKey + " for " + toPublicKey);
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ export function ProtocolProvider(props : ProtocolProviderProps) {
|
|||||||
deviceOs: systemInfo.os
|
deviceOs: systemInfo.os
|
||||||
}
|
}
|
||||||
protocol.connect();
|
protocol.connect();
|
||||||
//protocol.startHandshakeExchange(publicKey, privateKey, device);
|
const connect = () => {
|
||||||
protocol.on('connect', () => {
|
|
||||||
console.info("Connected to server, starting handshake exchange");
|
console.info("Connected to server, starting handshake exchange");
|
||||||
protocol.startHandshakeExchange(publicKey, privateKey, device);
|
protocol.startHandshakeExchange(publicKey, privateKey, device);
|
||||||
/**
|
/**
|
||||||
@@ -54,24 +53,41 @@ export function ProtocolProvider(props : ProtocolProviderProps) {
|
|||||||
* так как при переподключении они слетают
|
* так как при переподключении они слетают
|
||||||
*/
|
*/
|
||||||
setOnlineSubscribes([]);
|
setOnlineSubscribes([]);
|
||||||
});
|
}
|
||||||
protocol.on('reconnect', () => {
|
const reconnect = () => {
|
||||||
log("Connection lost, reconnecting and starting handshake exchange");
|
log("Connection lost, reconnecting and starting handshake exchange");
|
||||||
setConnect(ProtocolState.RECONNECTING);
|
setConnect(ProtocolState.RECONNECTING);
|
||||||
});
|
}
|
||||||
protocol.on('handshake_start', () => {
|
const handshake_start = () => {
|
||||||
log("Handshake exchange started");
|
log("Handshake exchange started");
|
||||||
setConnect(ProtocolState.HANDSHAKE_EXCHANGE);
|
setConnect(ProtocolState.HANDSHAKE_EXCHANGE);
|
||||||
});
|
}
|
||||||
protocol.on('handshake_complete', () => {
|
const handshake_complete = () => {
|
||||||
log("Handshake exchange complete");
|
log("Handshake exchange complete");
|
||||||
setConnect(ProtocolState.CONNECTED);
|
setConnect(ProtocolState.CONNECTED);
|
||||||
});
|
}
|
||||||
protocol.on('handshake_need_device_verification', () => {
|
const handshake_need_device_verification = () => {
|
||||||
log("Handshake exchange needs device verification");
|
log("Handshake exchange needs device verification");
|
||||||
setConnect(ProtocolState.DEVICE_VERIFICATION_REQUIRED);
|
setConnect(ProtocolState.DEVICE_VERIFICATION_REQUIRED);
|
||||||
navigate('/deviceconfirm');
|
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]);
|
}, [publicKey, privateKey, systemInfo.id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user