Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mail view update race condition when opening mails from notification #8473

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/mail-app/mail/view/MailViewerViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,14 @@ export class MailViewerViewModel {
for (const update of events) {
if (isUpdateForTypeRef(MailTypeRef, update)) {
const { instanceListId, instanceId, operation } = update
if (operation === OperationType.UPDATE && isSameId(this.mail._id, [instanceListId, instanceId])) {
// we need to process create events here because update and create events are optimized into a single create event during processing
// when opening a mail from a notification while offline the view otherwise would not be updated when going online again,
// and we would keep displaying an outdated view of the mail instance. timeline:
// CREATE > Loaded and cached > Opened offline > Online > UPDATE (e.g. ownerEncSessionKey) > entity event processing starts
// CREATE and UPDATE are merged into single CREATE event > CREATE event is processed here
// and would be ignored even though the update is from after we loaded the mail.
// This is critical as it also concerns encryptionAuthStatus
if ((operation === OperationType.UPDATE || operation === OperationType.CREATE) && isSameId(this.mail._id, [instanceListId, instanceId])) {
try {
const updatedMail = await this.entityClient.load(MailTypeRef, this.mail._id)
this.updateMail({ mail: updatedMail })
Expand Down