@bobfrankston/mailx 1.0.198 → 1.0.199

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx",
3
- "version": "1.0.198",
3
+ "version": "1.0.199",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",
@@ -23,8 +23,8 @@
23
23
  "@bobfrankston/iflow-direct": "^0.1.6",
24
24
  "@bobfrankston/iflow-node": "^0.1.2",
25
25
  "@bobfrankston/miscinfo": "^1.0.8",
26
- "@bobfrankston/oauthsupport": "^1.0.21",
27
- "@bobfrankston/msger": "^0.1.249",
26
+ "@bobfrankston/oauthsupport": "^1.0.22",
27
+ "@bobfrankston/msger": "^0.1.250",
28
28
  "@capacitor/android": "^8.3.0",
29
29
  "@capacitor/cli": "^8.3.0",
30
30
  "@capacitor/core": "^8.3.0",
@@ -396,11 +396,16 @@ export class MailxService {
396
396
  const envelope = this.db.getMessageByUid(accountId, uid);
397
397
  if (!envelope)
398
398
  throw new Error("Message not found");
399
+ // Update local DB immediately (local-first)
400
+ this.db.updateMessageFolder(accountId, uid, targetFolderId);
401
+ this.db.recalcFolderCounts(envelope.folderId);
402
+ this.db.recalcFolderCounts(targetFolderId);
403
+ // Sync to server in background
399
404
  if (targetAccountId && targetAccountId !== accountId) {
400
- await this.imapManager.moveMessageCrossAccount(accountId, envelope.uid, envelope.folderId, targetAccountId, targetFolderId);
405
+ this.imapManager.moveMessageCrossAccount(accountId, envelope.uid, envelope.folderId, targetAccountId, targetFolderId).catch(e => console.error(` Move sync failed: ${e.message}`));
401
406
  }
402
407
  else {
403
- await this.imapManager.moveMessage(accountId, envelope.uid, envelope.folderId, targetFolderId);
408
+ this.imapManager.moveMessage(accountId, envelope.uid, envelope.folderId, targetFolderId).catch(e => console.error(` Move sync failed: ${e.message}`));
404
409
  }
405
410
  }
406
411
  async moveMessages(accountId, uids, targetFolderId) {
@@ -410,7 +415,16 @@ export class MailxService {
410
415
  return null;
411
416
  return { uid: env.uid, folderId: env.folderId };
412
417
  }).filter(m => m !== null);
413
- await this.imapManager.moveMessages(accountId, messages, targetFolderId);
418
+ // Update local DB immediately
419
+ for (const msg of messages) {
420
+ if (msg) {
421
+ this.db.updateMessageFolder(accountId, msg.uid, targetFolderId);
422
+ this.db.recalcFolderCounts(msg.folderId);
423
+ }
424
+ }
425
+ this.db.recalcFolderCounts(targetFolderId);
426
+ // Sync to server in background
427
+ this.imapManager.moveMessages(accountId, messages, targetFolderId).catch(e => console.error(` Move sync failed: ${e.message}`));
414
428
  }
415
429
  async undeleteMessage(accountId, uid, folderId) {
416
430
  await this.imapManager.undeleteMessage(accountId, uid, folderId);
@@ -57,6 +57,7 @@ export declare class MailxDB {
57
57
  getMessageByUid(accountId: string, uid: number, folderId?: number): MessageEnvelope;
58
58
  getMessageBodyPath(accountId: string, uid: number): string;
59
59
  updateMessageFlags(accountId: string, uid: number, flags: string[]): void;
60
+ updateMessageFolder(accountId: string, uid: number, targetFolderId: number): void;
60
61
  updateBodyPath(accountId: string, uid: number, bodyPath: string): void;
61
62
  /** Get messages without cached bodies (for background prefetch) */
62
63
  getMessagesWithoutBody(accountId: string, limit?: number): {
@@ -317,6 +317,9 @@ export class MailxDB {
317
317
  updateMessageFlags(accountId, uid, flags) {
318
318
  this.db.prepare("UPDATE messages SET flags_json = ? WHERE account_id = ? AND uid = ?").run(JSON.stringify(flags), accountId, uid);
319
319
  }
320
+ updateMessageFolder(accountId, uid, targetFolderId) {
321
+ this.db.prepare("UPDATE messages SET folder_id = ? WHERE account_id = ? AND uid = ?").run(targetFolderId, accountId, uid);
322
+ }
320
323
  updateBodyPath(accountId, uid, bodyPath) {
321
324
  this.db.prepare("UPDATE messages SET body_path = ? WHERE account_id = ? AND uid = ?").run(bodyPath, accountId, uid);
322
325
  }