Menu ▾ ▴

#352 Read unread and mute state from Messenger's database instead of the DOM

closed
nobody
2026-11-07
2026-11-07
Anonymous
No

Originally created by: kristofferR

Problem

Unread and mute state is inferred from rendering:

  • The unread badge counts rows whose preview text has a bold getComputedStyle(span).fontWeight (unread-badge.ts:67).
  • Muted conversations are detected from localized label words in 8 languages, an SVG path hash and pixel offsets, plus a persistent store for rows that scroll out of view (lib/mute.ts:12-30).

Both break on new locales, theme or markup changes, and on rows that are not rendered.

Design

  • Add a small shared helper over Messenger's local database (LSDatabaseSingleton + ReQL, already imported in notification-names.ts (github.com)).
  • Unread: MWPIsThreadUnread.isThreadUnreadForViewer(thread) over the threads table. Mute: thread.muteExpireTimeMs (in the future, or the "forever" sentinel).
  • Recount only when the database or the chat list changes (fMess uses a MutationObserver trigger, 15-unread-badge.js:10-45; 14-notifications.js:239-270), not on a timer.
  • Keep the DOM path as a fallback when the modules are unavailable, and log a diagnostics line when it is used.
  • This also covers [#253] (unread across inbox filters), since the database is not limited to the visible filter.

Ref [#253]. Shares the database helper with the Do Not Disturb and recent-threads issues.

Testing

  • Badge matches Messenger's own count across languages (at least English, Norwegian, an RTL locale), including conversations below the fold.
  • Mute for 1 hour, mute forever, unmute: badge and notifications follow, with no reload.
  • Unit-test the helper against fixture rows.

Part of [#349].

Related

Tickets: #253
Tickets: #349
Tickets: #376

Discussion

  • Anonymous

    Anonymous - 2026-11-07

    Originally posted by: kristofferR

    [!NOTE]
    🤖 Claude Opus 5.5 responding on behalf of Kristoffer

    Landed in [#376]: unread and mute state come from Messenger's database instead of the DOM.

    It is on main and ships in the next release.

     

    Related

    Tickets: #376

  • Anonymous

    Anonymous - 2026-11-07

    Ticket changed by: kristofferR

    • status: open --> closed
     

Log in to post a comment.