Исправить UI статусы DM

This commit is contained in:
AidarKC
2026-07-10 11:57:00 +04:00
parent bb92cb6b2b
commit 2b23aa7b95
4 changed files with 39 additions and 6 deletions
+2 -2
View File
@@ -1,2 +1,2 @@
client.version=1.2.302 client.version=1.2.303
server.version=1.2.281 server.version=1.2.282
+14 -1
View File
@@ -892,6 +892,15 @@ function refreshToolbarOnly() {
refreshConnectionUi(); refreshConnectionUi();
} }
function refreshUnreadUi() {
const pageId = getRoute().pageId || '';
if (pageId === 'messages-list') {
renderApp();
return;
}
refreshToolbarOnly();
}
async function tryAutoLogin() { async function tryAutoLogin() {
if (!state.session.login || !state.session.sessionId) return; if (!state.session.login || !state.session.sessionId) return;
try { try {
@@ -1151,7 +1160,9 @@ async function init() {
if (messageType === 3) { if (messageType === 3) {
markOutgoingReadByBaseKey(refBaseKey); markOutgoingReadByBaseKey(refBaseKey);
} else { } else {
markIncomingReadByBaseKey(refBaseKey); if (markIncomingReadByBaseKey(refBaseKey)) {
shouldRefreshToolbarUnread = true;
}
} }
} }
addAppLogEntry({ addAppLogEntry({
@@ -1214,6 +1225,8 @@ async function init() {
try { await handleIncomingCallInvite(evt); } catch {} try { await handleIncomingCallInvite(evt); } catch {}
}); });
window.addEventListener('shine-unread-state-updated', refreshUnreadUi);
authService.onEvent('IncomingCallSignal', async (evt) => { authService.onEvent('IncomingCallSignal', async (evt) => {
try { await handleIncomingCallSignal(evt); } catch {} try { await handleIncomingCallSignal(evt); } catch {}
}); });
+17 -2
View File
@@ -619,11 +619,19 @@ export function render({ navigate, route }) {
revisionTimeMs: Number(parsed?.revisionTimeMs || 0), revisionTimeMs: Number(parsed?.revisionTimeMs || 0),
deleted: Boolean(parsed?.deleted), deleted: Boolean(parsed?.deleted),
}); });
return true;
} catch { } catch {
// ignore local parse failure; server backlog/realtime will reconcile later // ignore local parse failure; server backlog/realtime will reconcile later
return false;
} }
}; };
const notifyUnreadStateUpdated = () => {
window.dispatchEvent(new CustomEvent('shine-unread-state-updated', {
detail: { chatId },
}));
};
const sendDeleteRevision = async (msg) => { const sendDeleteRevision = async (msg) => {
const base = parseBaseKey(msg?.baseKey); const base = parseBaseKey(msg?.baseKey);
if (!base) return; if (!base) return;
@@ -681,7 +689,7 @@ export function render({ navigate, route }) {
}); });
} }
void applyLocalRevision({ const localRevisionApplied = await applyLocalRevision({
localOutgoingBlobB64: result?.localOutgoingBlobB64 || '', localOutgoingBlobB64: result?.localOutgoingBlobB64 || '',
fallbackMessageKey: result?.outgoingKey || '', fallbackMessageKey: result?.outgoingKey || '',
fallbackBaseKey: result?.baseKey || result?.localBaseKey || '', fallbackBaseKey: result?.baseKey || result?.localBaseKey || '',
@@ -692,6 +700,9 @@ export function render({ navigate, route }) {
} }
renderLog(log, chatId, { onOpenActions: handleOpenActions }); renderLog(log, chatId, { onOpenActions: handleOpenActions });
if (localRevisionApplied) {
notifyUnreadStateUpdated();
}
scrollToLatestMessageSmart(log, { smoothIfNearBottom: true }); scrollToLatestMessageSmart(log, { smoothIfNearBottom: true });
window.requestAnimationFrame(() => scrollToLatestMessageSmart(log, { smoothIfNearBottom: true })); window.requestAnimationFrame(() => scrollToLatestMessageSmart(log, { smoothIfNearBottom: true }));
window.setTimeout(() => scrollToLatestMessageSmart(log, { smoothIfNearBottom: true }), 220); window.setTimeout(() => scrollToLatestMessageSmart(log, { smoothIfNearBottom: true }), 220);
@@ -841,7 +852,11 @@ export function render({ navigate, route }) {
window.requestAnimationFrame(() => scrollToLatestMessage(log)); window.requestAnimationFrame(() => scrollToLatestMessage(log));
window.setTimeout(() => scrollToLatestMessage(log), 180); window.setTimeout(() => scrollToLatestMessage(log), 180);
} }
window.setTimeout(() => markChatRead(chatId), 220); window.setTimeout(() => {
if (markChatRead(chatId) > 0) {
notifyUnreadStateUpdated();
}
}, 220);
void sendReadReceiptsForVisible(chatId); void sendReadReceiptsForVisible(chatId);
screen.cleanup = () => { screen.cleanup = () => {
setChatKeyboardOpen(false); setChatKeyboardOpen(false);
+6 -1
View File
@@ -577,6 +577,7 @@ export function markOutgoingReadByBaseKey(baseKey) {
} else { } else {
state.pendingOutgoingReadByBaseKey[baseKey] = true; state.pendingOutgoingReadByBaseKey[baseKey] = true;
} }
return matched;
} }
export function markIncomingReadByBaseKey(baseKey) { export function markIncomingReadByBaseKey(baseKey) {
@@ -600,6 +601,7 @@ export function markIncomingReadByBaseKey(baseKey) {
} else { } else {
state.pendingIncomingReadByBaseKey[baseKey] = true; state.pendingIncomingReadByBaseKey[baseKey] = true;
} }
return matched;
} }
export function markReadReceiptSentByBaseKey(baseKey) { export function markReadReceiptSentByBaseKey(baseKey) {
@@ -727,12 +729,15 @@ export function deleteConversationMessagesBefore(chatId, boundaryTimeMs) {
export function markChatRead(chatId) { export function markChatRead(chatId) {
const normalizedChatId = normalizeDmChatId(chatId); const normalizedChatId = normalizeDmChatId(chatId);
const list = getChatMessages(normalizedChatId); const list = getChatMessages(normalizedChatId);
let changed = 0;
list.forEach((row) => { list.forEach((row) => {
if (row?.from === 'in') { if (row?.from === 'in' && row?.unread) {
row.unread = false; row.unread = false;
persistMessageRecord(normalizedChatId, row); persistMessageRecord(normalizedChatId, row);
changed += 1;
} }
}); });
return changed;
} }
export function setContacts(list) { export function setContacts(list) {