@bobfrankston/mailx-store 0.1.12 → 0.1.13
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/db.d.ts +16 -0
- package/db.js +29 -0
- package/package.json +1 -1
package/db.d.ts
CHANGED
|
@@ -253,6 +253,22 @@ export declare class MailxDB {
|
|
|
253
253
|
private _onContactsChanged?;
|
|
254
254
|
setOnContactsChanged(cb: () => void): void;
|
|
255
255
|
private notifyContactsChanged;
|
|
256
|
+
/** Fired when upsertMessage detects a server-side move (Message-ID match
|
|
257
|
+
* in another folder rebinds the existing row to the destination). The
|
|
258
|
+
* reconciler can listen and cancel any pending deferred-delete for the
|
|
259
|
+
* original (folder, uid), so the move propagates without the source
|
|
260
|
+
* folder's reconcile-delete firing 30 minutes later for a row that's
|
|
261
|
+
* been rebound elsewhere. */
|
|
262
|
+
private _onMoveDetected?;
|
|
263
|
+
setOnMoveDetected(cb: (info: {
|
|
264
|
+
accountId: string;
|
|
265
|
+
messageId: string;
|
|
266
|
+
fromFolderId: number;
|
|
267
|
+
fromUid: number;
|
|
268
|
+
toFolderId: number;
|
|
269
|
+
toUid: number;
|
|
270
|
+
rowId: number;
|
|
271
|
+
}) => void): void;
|
|
256
272
|
/** Seed `discovered`-tier contacts from every address that appears in
|
|
257
273
|
* any cached message — From / To / Cc / Bcc across all folders. One row
|
|
258
274
|
* per email; first non-empty name observed wins. Sent-folder rows skip
|
package/db.js
CHANGED
|
@@ -1045,6 +1045,25 @@ export class MailxDB {
|
|
|
1045
1045
|
// Update folder_id + uid; preserve uuid, body_path, flags
|
|
1046
1046
|
// (server flags will catch up on the next full sync).
|
|
1047
1047
|
this.db.prepare("UPDATE messages SET folder_id = ?, uid = ?, cached_at = ? WHERE id = ?").run(msg.folderId, msg.uid, Date.now(), moved.id);
|
|
1048
|
+
// Notify subscribers so e.g. the reconciler can cancel any
|
|
1049
|
+
// pending deferred-delete for the original (folder, uid) —
|
|
1050
|
+
// otherwise the reconcile-delete grace timer fires for a
|
|
1051
|
+
// row that's been rebound elsewhere, and the user sees the
|
|
1052
|
+
// moved message vanish 30 minutes after the move.
|
|
1053
|
+
if (this._onMoveDetected) {
|
|
1054
|
+
try {
|
|
1055
|
+
this._onMoveDetected({
|
|
1056
|
+
accountId: msg.accountId,
|
|
1057
|
+
messageId: msg.messageId,
|
|
1058
|
+
fromFolderId: moved.folder_id,
|
|
1059
|
+
fromUid: moved.uid,
|
|
1060
|
+
toFolderId: msg.folderId,
|
|
1061
|
+
toUid: msg.uid,
|
|
1062
|
+
rowId: moved.id,
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
catch { /* listener errors must not break sync */ }
|
|
1066
|
+
}
|
|
1048
1067
|
return moved.id;
|
|
1049
1068
|
}
|
|
1050
1069
|
}
|
|
@@ -1386,6 +1405,16 @@ export class MailxDB {
|
|
|
1386
1405
|
}
|
|
1387
1406
|
catch { /* ignore */ }
|
|
1388
1407
|
}
|
|
1408
|
+
/** Fired when upsertMessage detects a server-side move (Message-ID match
|
|
1409
|
+
* in another folder rebinds the existing row to the destination). The
|
|
1410
|
+
* reconciler can listen and cancel any pending deferred-delete for the
|
|
1411
|
+
* original (folder, uid), so the move propagates without the source
|
|
1412
|
+
* folder's reconcile-delete firing 30 minutes later for a row that's
|
|
1413
|
+
* been rebound elsewhere. */
|
|
1414
|
+
_onMoveDetected;
|
|
1415
|
+
setOnMoveDetected(cb) {
|
|
1416
|
+
this._onMoveDetected = cb;
|
|
1417
|
+
}
|
|
1389
1418
|
/** Seed `discovered`-tier contacts from every address that appears in
|
|
1390
1419
|
* any cached message — From / To / Cc / Bcc across all folders. One row
|
|
1391
1420
|
* per email; first non-empty name observed wins. Sent-folder rows skip
|