Debug onReadMessage call with read sync timestamp
This commit is contained in:
parent
190ec43703
commit
05a2286d94
1 changed files with 14 additions and 12 deletions
|
@ -13,6 +13,7 @@ import { isIncoming } from '../state/selectors/message';
|
||||||
import { isMessageUnread } from '../util/isMessageUnread';
|
import { isMessageUnread } from '../util/isMessageUnread';
|
||||||
import { notificationService } from '../services/notifications';
|
import { notificationService } from '../services/notifications';
|
||||||
import { queueUpdateMessage } from '../util/messageBatcher';
|
import { queueUpdateMessage } from '../util/messageBatcher';
|
||||||
|
import { strictAssert } from '../util/assert';
|
||||||
|
|
||||||
export type ReadSyncAttributesType = {
|
export type ReadSyncAttributesType = {
|
||||||
envelopeId: string;
|
envelopeId: string;
|
||||||
|
@ -125,32 +126,33 @@ export async function onSync(sync: ReadSyncAttributesType): Promise<void> {
|
||||||
message.markRead(readAt, { skipSave: true });
|
message.markRead(readAt, { skipSave: true });
|
||||||
|
|
||||||
const updateConversation = async () => {
|
const updateConversation = async () => {
|
||||||
|
const conversation = message.getConversation();
|
||||||
|
strictAssert(conversation, `${logId}: conversation not found`);
|
||||||
// onReadMessage may result in messages older than this one being
|
// onReadMessage may result in messages older than this one being
|
||||||
// marked read. We want those messages to have the same expire timer
|
// marked read. We want those messages to have the same expire timer
|
||||||
// start time as this one, so we pass the readAt value through.
|
// start time as this one, so we pass the readAt value through.
|
||||||
drop(
|
drop(conversation.onReadMessage(message, readAt, newestSentAt));
|
||||||
message
|
|
||||||
.getConversation()
|
|
||||||
?.onReadMessage(message, readAt, newestSentAt)
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// only available during initialization
|
// only available during initialization
|
||||||
if (StartupQueue.isAvailable()) {
|
if (StartupQueue.isAvailable()) {
|
||||||
const conversation = message.getConversation();
|
const conversation = message.getConversation();
|
||||||
if (conversation) {
|
strictAssert(
|
||||||
StartupQueue.add(
|
conversation,
|
||||||
conversation.get('id'),
|
`${logId}: conversation not found (StartupQueue)`
|
||||||
message.get('sent_at'),
|
);
|
||||||
updateConversation
|
StartupQueue.add(
|
||||||
);
|
conversation.get('id'),
|
||||||
}
|
message.get('sent_at'),
|
||||||
|
updateConversation
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// not awaiting since we don't want to block work happening in the
|
// not awaiting since we don't want to block work happening in the
|
||||||
// eventHandlerQueue
|
// eventHandlerQueue
|
||||||
drop(updateConversation());
|
drop(updateConversation());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
log.info(`${logId}: updating expiration`);
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const existingTimestamp = message.get('expirationStartTimestamp');
|
const existingTimestamp = message.get('expirationStartTimestamp');
|
||||||
const expirationStartTimestamp = Math.min(
|
const expirationStartTimestamp = Math.min(
|
||||||
|
|
Loading…
Add table
Reference in a new issue