Синхронизация и фикс двойного сокета
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -11,4 +11,5 @@ LICENSE
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.production.local
|
||||
app/servers.ts
|
||||
@@ -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]);
|
||||
/**
|
||||
* Обработчик прочтения групповых сообщений
|
||||
*/
|
||||
|
||||
@@ -43,7 +43,7 @@ export default class Protocol extends EventEmitter {
|
||||
super();
|
||||
this.serverAddress = serverAddress;
|
||||
this.loadAllSupportedPackets();
|
||||
this.connect();
|
||||
//this.connect();
|
||||
|
||||
let _this = this;
|
||||
this.waitPacket(0x00, (packet : PacketHandshake) => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export const SERVERS = [
|
||||
//'wss://cdn.rosetta-im.com',
|
||||
'ws://10.211.55.2:3000'
|
||||
//'ws://10.211.55.2:3000',
|
||||
'ws://127.0.0.1:8881'
|
||||
];
|
||||
|
||||
export function selectServer(): string {
|
||||
|
||||
Reference in New Issue
Block a user