@bobfrankston/mailx-store 0.1.40 → 0.1.41

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 (4) hide show
  1. package/db.d.ts +9 -1
  2. package/db.js +15 -2
  3. package/package.json +1 -1
  4. package/store.js +1 -1
package/db.d.ts CHANGED
@@ -302,7 +302,15 @@ export declare class MailxDB {
302
302
  * Existing callers without folderId are tolerated (legacy) but should
303
303
  * be migrated. */
304
304
  getMessageBodyPath(accountId: string, uid: number, folderId?: number): string;
305
- updateMessageFlags(accountId: string, uid: number, flags: string[]): void;
305
+ /** Update flags for a message. folderId is REQUIRED — same UID-collision
306
+ * bug class as the deleteMessage one we fixed 2026-05-27. The
307
+ * WHERE-account-AND-uid query previously updated EVERY folder's row
308
+ * that shared the numeric UID, causing the "stars on letters I never
309
+ * starred" symptom (Bob 2026-05-27: flagging one INBOX message lit
310
+ * up stars on a same-numeric-UID row in Drafts/Sent/sub-folders).
311
+ * folderId === null is allowed as an explicit "every folder" override
312
+ * for code paths that mean it; everyone else must pass folderId. */
313
+ updateMessageFlags(accountId: string, folderId: number | null, uid: number, flags: string[]): void;
306
314
  updateMessageFolder(accountId: string, uid: number, targetFolderId: number): void;
307
315
  /** Local-first move of a message between folders. Updates BOTH the
308
316
  * legacy `messages.folder_id` column AND the `message_folders`
package/db.js CHANGED
@@ -1815,8 +1815,21 @@ export class MailxDB {
1815
1815
  : this.db.prepare("SELECT body_path FROM messages WHERE account_id = ? AND uid = ?").get(accountId, uid);
1816
1816
  return r?.body_path || "";
1817
1817
  }
1818
- updateMessageFlags(accountId, uid, flags) {
1819
- this.db.prepare("UPDATE messages SET flags_json = ? WHERE account_id = ? AND uid = ?").run(JSON.stringify(flags), accountId, uid);
1818
+ /** Update flags for a message. folderId is REQUIRED — same UID-collision
1819
+ * bug class as the deleteMessage one we fixed 2026-05-27. The
1820
+ * WHERE-account-AND-uid query previously updated EVERY folder's row
1821
+ * that shared the numeric UID, causing the "stars on letters I never
1822
+ * starred" symptom (Bob 2026-05-27: flagging one INBOX message lit
1823
+ * up stars on a same-numeric-UID row in Drafts/Sent/sub-folders).
1824
+ * folderId === null is allowed as an explicit "every folder" override
1825
+ * for code paths that mean it; everyone else must pass folderId. */
1826
+ updateMessageFlags(accountId, folderId, uid, flags) {
1827
+ if (folderId != null) {
1828
+ this.db.prepare("UPDATE messages SET flags_json = ? WHERE account_id = ? AND folder_id = ? AND uid = ?").run(JSON.stringify(flags), accountId, folderId, uid);
1829
+ }
1830
+ else {
1831
+ this.db.prepare("UPDATE messages SET flags_json = ? WHERE account_id = ? AND uid = ?").run(JSON.stringify(flags), accountId, uid);
1832
+ }
1820
1833
  }
1821
1834
  updateMessageFolder(accountId, uid, targetFolderId) {
1822
1835
  // Idempotency: if a row already exists at (account, target_folder, uid)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-store",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/store.js CHANGED
@@ -450,7 +450,7 @@ export class Store {
450
450
  * `folder:<id>` (auto fan-out)
451
451
  */
452
452
  updateFlags(accountId, uid, folderId, flags) {
453
- this.db.updateMessageFlags(accountId, uid, flags);
453
+ this.db.updateMessageFlags(accountId, folderId, uid, flags);
454
454
  const env = this.db.getMessageByUid(accountId, uid, folderId);
455
455
  const msgUuid = env?.uuid;
456
456
  if (msgUuid) {