Skip to content

fix: sync unread counters after delete/archive operations (Closes #1404)#1408

Closed
kuishou68 wants to merge 1 commit into
floatpane:masterfrom
kuishou68:fix/issue-1404-unread-counter
Closed

fix: sync unread counters after delete/archive operations (Closes #1404)#1408
kuishou68 wants to merge 1 commit into
floatpane:masterfrom
kuishou68:fix/issue-1404-unread-counter

Conversation

@kuishou68
Copy link
Copy Markdown

@kuishou68 kuishou68 commented Jun 2, 2026

Problem

After deleting or archiving emails, the unread badge counter does not update immediately. The counter only refreshes on the next fetch cycle, leading to stale UI state.

Root Cause

Four message handlers in main.go remove emails from stores but never call m.syncUnreadBadge() to recalculate the dock badge:

  • DeleteEmailMsg (line 1785)
  • ArchiveEmailMsg (line 1818)
  • BatchDeleteEmailsMsg (line 1879)
  • BatchArchiveEmailsMsg (line 1913)

Compare with EmailMarkedReadMsg and EmailMarkedUnreadMsg which correctly call m.syncUnreadBadge() after updating state.

Fix

Added m.syncUnreadBadge() call before the return statement in all four handlers, consistent with the existing pattern used by EmailMarkedReadMsg and EmailMarkedUnreadMsg.

Co-authored-by: kuishou68 54054995+kuishou68@users.noreply.github.com
Co-authored-by: pojian68 232320289+pojian68@users.noreply.github.com
Signed-off-by: lingxiu58 86288566+lingxiu58@users.noreply.github.com

…atpane#1404)

Co-authored-by: kuishou68 <54054995+kuishou68@users.noreply.github.com>
Co-authored-by: pojian68 <232320289+pojian68@users.noreply.github.com>
Signed-off-by: lingxiu58 <86288566+lingxiu58@users.noreply.github.com>
@kuishou68 kuishou68 requested a review from a team as a code owner June 2, 2026 01:28
@floatpanebot floatpanebot added the bug Something isn't working label Jun 2, 2026
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Hi @kuishou68! Please fix the following issues with your PR:

  • Title: Is too long (72 characters). The PR title must be strictly under 40 characters.
  • Body: Missing the ## What? or ## Why? headings required by the PR template.

@floatpanebot floatpanebot added the size/S Diff: 11–50 lines label Jun 2, 2026
@floatpanebot
Copy link
Copy Markdown
Member

Benchmark report — no significant change

Metrics worse: 0 · better: 0 (threshold: ±3%).

benchstat output
goos: linux
goarch: amd64
pkg: github.com/floatpane/matcha/backend
cpu: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
                           │    old.txt    │               new.txt               │
                           │    sec/op     │    sec/op     vs base               │
ParseSearchQuery_Simple-4    2.181µ ± 400%   2.516µ ± 24%        ~ (p=0.699 n=6)
ParseSearchQuery_Complex-4   7.362µ ±  34%   7.194µ ± 31%        ~ (p=0.818 n=6)
TokenizeSearchQuery-4        3.160µ ± 147%   5.345µ ± 75%        ~ (p=0.093 n=6)
geomean                      3.702µ          4.590µ        +23.99%

                           │  old.txt   │              new.txt               │
                           │    B/op    │    B/op     vs base                │
ParseSearchQuery_Simple-4    26.00 ± 0%   26.00 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   762.0 ± 0%   762.0 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        176.0 ± 0%   176.0 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      151.6        151.6       +0.00%
¹ all samples are equal

                           │  old.txt   │              new.txt               │
                           │ allocs/op  │ allocs/op   vs base                │
ParseSearchQuery_Simple-4    2.000 ± 0%   2.000 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   23.00 ± 0%   23.00 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        9.000 ± 0%   9.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      7.453        7.453       +0.00%
¹ all samples are equal

pkg: github.com/floatpane/matcha/tui
                    │   old.txt    │              new.txt               │
                    │    sec/op    │    sec/op     vs base              │
LogPanelView-4        164.2µ ± 13%   151.6µ ± 20%       ~ (p=0.818 n=6)
SearchOverlayView-4   172.9µ ± 16%   175.9µ ± 14%       ~ (p=0.937 n=6)
InboxConstruction-4   896.2µ ±  4%   968.0µ ±  5%  +8.02% (p=0.004 n=6)
geomean               294.1µ         295.5µ        +0.47%

                    │    old.txt    │               new.txt               │
                    │     B/op      │     B/op       vs base              │
LogPanelView-4        44.67Ki ± 51%   44.67Ki ±  0%       ~ (p=0.455 n=6)
SearchOverlayView-4   56.14Ki ±  0%   56.14Ki ± 41%       ~ (p=0.848 n=6)
InboxConstruction-4   874.2Ki ±  0%   874.3Ki ±  0%       ~ (p=0.937 n=6)
geomean               129.9Ki         129.9Ki        +0.00%

                    │   old.txt   │              new.txt              │
                    │  allocs/op  │  allocs/op   vs base              │
LogPanelView-4         714.0 ± 0%    714.0 ± 0%       ~ (p=0.455 n=6)
SearchOverlayView-4    926.0 ± 0%    926.0 ± 0%       ~ (p=1.000 n=6)
InboxConstruction-4   3.478k ± 0%   3.478k ± 0%       ~ (p=1.000 n=6)
geomean               1.320k        1.320k       +0.00%

auto-generated by benchmarks.yml

@mavonx
Copy link
Copy Markdown
Member

mavonx commented Jun 2, 2026

@kuishou68

Please follow our format for writing pull request titles and descriptions. I'll review your PR after fixing it.

@andrinoff
Copy link
Copy Markdown
Member

@kuishou68 who are the random co-authors?

@kuishou68 kuishou68 closed this Jun 2, 2026
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Hi @andrinoff! Please fix the following issues with your PR:

  • Title: Is too long (72 characters). The PR title must be strictly under 40 characters.
  • Body: Missing the ## What? or ## Why? headings required by the PR template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size/S Diff: 11–50 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants