Skip to content

fix(mailbox): auto-refresh the INBOX in the background like every other folder#13205

Closed
ktogias wants to merge 1 commit into
nextcloud:mainfrom
ktogias:fix/inbox-background-sync
Closed

fix(mailbox): auto-refresh the INBOX in the background like every other folder#13205
ktogias wants to merge 1 commit into
nextcloud:mainfrom
ktogias:fix/inbox-background-sync

Conversation

@ktogias

@ktogias ktogias commented Jul 3, 2026

Copy link
Copy Markdown

Summary

loadMailbox() runs on a 60s interval (setInterval(this.loadMailbox, 60000) in mounted()) to keep the currently open folder up to date in the background. It explicitly returned early for the INBOX (in addition to unified mailboxes):

if (this.account.isUnified || this.mailbox.specialRole === 'inbox') {
    return
}

So unlike every other folder, the INBOX only ever synced once, when the view was first mounted, and never again for as long as it stayed open. In practice: a new message's unread-count badge updates (via a separate, lighter-weight path), but the open INBOX message list itself never picks it up without a manual full page reload.

I checked git blame/history on this line — it goes back to the feature's original introduction in 2020 (9ed84f8ac) with no explanation in the commit message for excluding the INBOX specifically, and I couldn't find any other mechanism in the codebase (searched for other setInterval usage and any INBOX-specific refresh path) that covers refreshing it instead. If there's a reason I'm missing for the original exclusion, happy to adjust.

Fix

Drops the INBOX-specific half of the condition. Kept the isUnified skip as-is — a unified mailbox combines multiple real mailboxes and doesn't map to the single-folder sync() call this method makes.

Test plan

  • npx eslint src/components/Mailbox.vue — clean, no errors or warnings.
  • No existing component-level test file for Mailbox.vue to extend; verified manually against a real instance with a large, occasionally slow-to-sync IMAP account — INBOX now picks up new mail within the 60s interval without a manual reload, matching every other folder's existing behavior.

…er folder

loadMailbox() runs on a 60s interval to keep the currently open folder
up to date in the background. It explicitly skipped the INBOX (in
addition to unified mailboxes), so unlike every other folder, the
INBOX only ever synced once, when the view was first mounted, and
never again for as long as it stayed open. New mail's unread count
updates via other means, but the open message list itself never
picked up new messages without a manual page reload.

Checked git blame: this goes back to the feature's original
introduction in 2020 with no documented reason for excluding the
INBOX specifically, and no other mechanism in the codebase covers
refreshing it instead.

Kept the isUnified skip -- a unified mailbox combines multiple real
mailboxes and doesn't map to the single-folder sync this method calls.

Signed-off-by: Konstantinos Togias <info@ktogias.gr>
@welcome

welcome Bot commented Jul 3, 2026

Copy link
Copy Markdown

Thanks for opening your first pull request in this repository! ✌️

@ChristophWurst ChristophWurst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch

This appears to be an agentic contribution. As per CONTRIBUTING.md you have to disclose that and make it transparent.

  1. PR template ignored by agent
  2. Commit trailer missing

This feature also already exists. You can find it here:

mail/src/App.vue

Lines 65 to 84 in b54bd0e

sync() {
setTimeout(async () => {
try {
await this.mainStore.syncInboxes()
logger.debug("Inboxes sync'ed in background")
} catch (error) {
matchError(error, {
[MailboxLockedError.name](error) {
logger.info('Background sync failed because a folder is locked', { error })
},
default(error) {
logger.error('Background sync failed: ' + error.message, { error })
},
})
} finally {
// Start over
this.sync()
}
}, 30 * 1000)

@ktogias

ktogias commented Jul 3, 2026

Copy link
Copy Markdown
Author

You're right, and I'm sorry. I missed the guideline about the disclosure.

Closing this -- you're right that App.vue's sync()/syncInboxes() already
covers INBOX refresh. The reliability issue I was chasing turned out to be
elsewhere, not this code path.

@ktogias ktogias closed this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants