Фикс ошибки чтения

This commit is contained in:
RoyceDa
2026-02-26 20:54:52 +02:00
parent b9603462a0
commit c3a53b517e
2 changed files with 10 additions and 7 deletions

View File

@@ -295,7 +295,6 @@ export function DialogProvider(props: DialogProviderProps) {
* Обработчик чтения для личных сообщений
*/
usePacket(0x07, async (packet : PacketRead) => {
info("Read packet received in dialog provider");
const fromPublicKey = packet.getFromPublicKey();
if(fromPublicKey == publicKey){
/**
@@ -309,7 +308,10 @@ export function DialogProvider(props: DialogProviderProps) {
*/
return;
}
if(fromPublicKey != props.dialog && !idle){
if(idle){
return;
}
if(fromPublicKey != props.dialog){
return;
}
setMessages((prev) => prev.map((msg) => {
@@ -342,7 +344,10 @@ export function DialogProvider(props: DialogProviderProps) {
*/
return;
}
if(toPublicKey != props.dialog && !idle){
if(idle){
return;
}
if(toPublicKey != props.dialog){
return;
}
setMessages((prev) => prev.map((msg) => {

View File

@@ -367,13 +367,11 @@ export function useDialogFiber() {
return;
}
await updateSyncTime(Date.now());
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]);
console.info("read im with params ", [fromPublicKey, toPublicKey, publicKey]);
updateDialog(fromPublicKey);
log("Read packet received from " + fromPublicKey + " for " + toPublicKey);
addOrUpdateDialogCache(fromPublicKey, getDialogCache(fromPublicKey).map((message) => {
if (message.from_public_key == toPublicKey && !message.readed) {
if (message.from_public_key == publicKey && !message.readed) {
console.info("Marking message as read in cache for dialog with " + fromPublicKey);
console.info({ fromPublicKey, toPublicKey });
return {