Merge branch 'main' of http://172.86.92.132/Rosetta/desktop
This commit is contained in:
@@ -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]);
|
||||
|
||||
/**
|
||||
* Обработчик прочтения личных сообщений
|
||||
*/
|
||||
|
||||
@@ -52,13 +52,13 @@ export default class Protocol extends EventEmitter {
|
||||
_this.emit('handshake_complete');
|
||||
_this.handshakeExchangeComplete = true;
|
||||
_this._flushPacketQueue();
|
||||
this.startHeartbeat(packet.getHeartbeatInterval());
|
||||
_this.startHeartbeat(packet.getHeartbeatInterval());
|
||||
}
|
||||
if(packet.getHandshakeState() == HandshakeState.NEED_DEVICE_VERIFICATION) {
|
||||
console.info('[protocol] %chandshake exchange need device verification', 'color: orange;');
|
||||
_this.emit('handshake_need_device_verification');
|
||||
_this._packetQueue = [];
|
||||
this.startHeartbeat(packet.getHeartbeatInterval());
|
||||
_this.startHeartbeat(packet.getHeartbeatInterval());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user