@bobfrankston/rmfmail 1.2.73 → 1.2.75

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.
@@ -2393,9 +2393,28 @@ export class MailxDB {
2393
2393
  * for code paths that mean it; everyone else must pass folderId. */
2394
2394
  updateMessageFlags(accountId: string, folderId: number | null, uid: number, flags: string[]): void {
2395
2395
  if (folderId != null) {
2396
- this.db.prepare(
2397
- "UPDATE messages SET flags_json = ? WHERE account_id = ? AND folder_id = ? AND uid = ?"
2398
- ).run(JSON.stringify(flags), accountId, folderId, uid);
2396
+ // Resolve the row via its folder MEMBERSHIP, not messages.folder_id.
2397
+ // The message-id collapse (upsertMessage move-detect) keeps ONE
2398
+ // `messages` row per message_id whose `folder_id` is an arbitrary
2399
+ // "primary" folder, while the message appears in OTHER folders via
2400
+ // `message_folders`. A `WHERE folder_id = ?` update therefore MISSED
2401
+ // any message viewed in a folder other than its stored primary —
2402
+ // 0 rows changed, so star/mark-read silently did nothing locally and
2403
+ // the change "came right back" on the next render (Bob 2026-06-27).
2404
+ // Match the membership (the same join getMessageByUid uses).
2405
+ const r = this.db.prepare(`
2406
+ UPDATE messages SET flags_json = ? WHERE id = (
2407
+ SELECT m.id FROM messages m
2408
+ JOIN message_folders mf ON mf.message_row_id = m.id
2409
+ WHERE m.account_id = ? AND mf.folder_id = ? AND mf.uid = ? LIMIT 1
2410
+ )
2411
+ `).run(JSON.stringify(flags), accountId, folderId, uid);
2412
+ // Fallback for any legacy row lacking a membership entry.
2413
+ if (r.changes === 0) {
2414
+ this.db.prepare(
2415
+ "UPDATE messages SET flags_json = ? WHERE account_id = ? AND folder_id = ? AND uid = ?"
2416
+ ).run(JSON.stringify(flags), accountId, folderId, uid);
2417
+ }
2399
2418
  } else {
2400
2419
  this.db.prepare(
2401
2420
  "UPDATE messages SET flags_json = ? WHERE account_id = ? AND uid = ?"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-types",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",