@bobfrankston/mailx-store 0.1.46 → 0.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/db.js +9 -2
  2. package/package.json +1 -1
package/db.js CHANGED
@@ -1803,17 +1803,24 @@ export class MailxDB {
1803
1803
  // The PARTITION BY collapses duplicates: keep the newest per
1804
1804
  // Message-ID. Empty Message-IDs (rare; non-RFC senders) are
1805
1805
  // grouped by row id so each gets its own bucket.
1806
+ //
1807
+ // Dedup is PER INBOX (account_id is in the partition key), not global.
1808
+ // The same Message-ID delivered to two different accounts' inboxes
1809
+ // (e.g. a list that hits both bob.ma and Gmail) is genuinely two
1810
+ // copies the user expects to see in All Inboxes — collapsing across
1811
+ // accounts hid the second one (Bob 2026-06-12). Within a single inbox,
1812
+ // the to-self N-copies case still collapses as before.
1806
1813
  const total = this.db.prepare(`SELECT COUNT(*) as cnt FROM (
1807
1814
  SELECT 1
1808
1815
  FROM messages m
1809
1816
  JOIN message_folders mf ON mf.message_row_id = m.id
1810
1817
  WHERE mf.folder_id IN (${placeholders})${flagFilter}
1811
- GROUP BY CASE WHEN COALESCE(m.message_id, '') = '' THEN 'mid-empty:' || m.id ELSE m.message_id END
1818
+ GROUP BY m.account_id, CASE WHEN COALESCE(m.message_id, '') = '' THEN 'mid-empty:' || m.id ELSE m.message_id END
1812
1819
  )`).get(...folderIds).cnt;
1813
1820
  const rows = this.db.prepare(`WITH ranked AS (
1814
1821
  SELECT m.id AS m_id, mf.uid AS mf_uid, mf.folder_id AS mf_folder_id,
1815
1822
  ROW_NUMBER() OVER (
1816
- PARTITION BY CASE WHEN COALESCE(m.message_id, '') = '' THEN 'mid-empty:' || m.id ELSE m.message_id END
1823
+ PARTITION BY m.account_id, CASE WHEN COALESCE(m.message_id, '') = '' THEN 'mid-empty:' || m.id ELSE m.message_id END
1817
1824
  ORDER BY m.date DESC, m.id DESC
1818
1825
  ) AS rn
1819
1826
  FROM messages m
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-store",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",