SHA256
Исправить восстановление DM после перелогина
This commit is contained in:
@@ -252,6 +252,8 @@ function createInitialState({ withStoredSession = true } = {}) {
|
||||
appLog: [],
|
||||
incomingDedup: {},
|
||||
knownMessageKeys: {},
|
||||
pendingOutgoingReadByBaseKey: {},
|
||||
pendingIncomingReadByBaseKey: {},
|
||||
outgoingTempSeq: 1,
|
||||
notificationsTab: 'replies',
|
||||
pageLabelCollapsed: false,
|
||||
@@ -558,32 +560,46 @@ export function markOutgoingSent(tempId, { messageKey = '', baseKey = '' } = {})
|
||||
export function markOutgoingReadByBaseKey(baseKey) {
|
||||
if (!baseKey) return;
|
||||
const keys = Object.keys(state.chats || {});
|
||||
let matched = false;
|
||||
keys.forEach((chatId) => {
|
||||
const list = getChatMessages(chatId);
|
||||
list.forEach((row) => {
|
||||
if (row?.from !== 'out') return;
|
||||
if (row.baseKey === baseKey) {
|
||||
matched = true;
|
||||
row.secondTick = true;
|
||||
persistMessageRecord(chatId, row);
|
||||
}
|
||||
});
|
||||
});
|
||||
if (matched) {
|
||||
delete state.pendingOutgoingReadByBaseKey[baseKey];
|
||||
} else {
|
||||
state.pendingOutgoingReadByBaseKey[baseKey] = true;
|
||||
}
|
||||
}
|
||||
|
||||
export function markIncomingReadByBaseKey(baseKey) {
|
||||
if (!baseKey) return;
|
||||
const keys = Object.keys(state.chats || {});
|
||||
let matched = false;
|
||||
keys.forEach((chatId) => {
|
||||
const list = getChatMessages(chatId);
|
||||
list.forEach((row) => {
|
||||
if (row?.from !== 'in') return;
|
||||
if (row.baseKey === baseKey) {
|
||||
matched = true;
|
||||
row.unread = false;
|
||||
row.readReceiptSent = true;
|
||||
persistMessageRecord(chatId, row);
|
||||
}
|
||||
});
|
||||
});
|
||||
if (matched) {
|
||||
delete state.pendingIncomingReadByBaseKey[baseKey];
|
||||
} else {
|
||||
state.pendingIncomingReadByBaseKey[baseKey] = true;
|
||||
}
|
||||
}
|
||||
|
||||
export function markReadReceiptSentByBaseKey(baseKey) {
|
||||
@@ -651,6 +667,15 @@ export function addSignedMessageToChat({
|
||||
row.firstTick = row.from === 'out';
|
||||
row.secondTick = Boolean(existing?.secondTick);
|
||||
row.readReceiptSent = Boolean(existing?.readReceiptSent);
|
||||
if (row.baseKey && row.from === 'out' && state.pendingOutgoingReadByBaseKey[row.baseKey]) {
|
||||
row.secondTick = true;
|
||||
delete state.pendingOutgoingReadByBaseKey[row.baseKey];
|
||||
}
|
||||
if (row.baseKey && row.from === 'in' && state.pendingIncomingReadByBaseKey[row.baseKey]) {
|
||||
row.unread = false;
|
||||
row.readReceiptSent = true;
|
||||
delete state.pendingIncomingReadByBaseKey[row.baseKey];
|
||||
}
|
||||
|
||||
if (existingIndex < 0) {
|
||||
list.push(row);
|
||||
@@ -872,6 +897,8 @@ function resetStateForSignedOut() {
|
||||
state.appLog = next.appLog;
|
||||
state.incomingDedup = next.incomingDedup;
|
||||
state.knownMessageKeys = next.knownMessageKeys;
|
||||
state.pendingOutgoingReadByBaseKey = next.pendingOutgoingReadByBaseKey;
|
||||
state.pendingIncomingReadByBaseKey = next.pendingIncomingReadByBaseKey;
|
||||
state.outgoingTempSeq = next.outgoingTempSeq;
|
||||
state.notificationsTab = next.notificationsTab;
|
||||
state.pageLabelCollapsed = next.pageLabelCollapsed;
|
||||
|
||||
Reference in New Issue
Block a user