@postalsys/ee-client 2.0.0 → 2.0.1
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/README.md +2 -2
- package/index.d.ts +7 -1
- package/index.js +27 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ new EmailEngineClient(options);
|
|
|
122
122
|
| `accessToken` | `string` | - | Bearer token for API authentication. |
|
|
123
123
|
| `container` | `HTMLElement` | - | DOM element to render the webmail UI into. Omit for API-only use. |
|
|
124
124
|
| `pageSize` | `number` | `20` | Messages per page. A saved value in `localStorage` takes precedence. |
|
|
125
|
-
| `confirmMethod` | `function` | browser `confirm()` | Custom confirm dialog, `(message, title, cancelText, okText)`. May be sync or async; returns a boolean.
|
|
125
|
+
| `confirmMethod` | `function` | browser `confirm()` | Custom confirm dialog, `(message, title, cancelText, okText)`. May be sync or async; returns a boolean, or `null` when the dialog was dismissed (see below). |
|
|
126
126
|
| `alertMethod` | `function` | browser `alert()` | Custom alert dialog, `(message, title, cancelText, okText)` where `cancelText` is `null`. |
|
|
127
127
|
| `darkMode` | `boolean` | stored preference | Initial dark mode. Overrides the preference stored by the builtin toggle. |
|
|
128
128
|
| `showDarkModeToggle` | `boolean` | `true` | Render the builtin dark mode toggle. Set `false` when the host application drives the mode through `client.setDarkMode(enabled)` (for example in sync with its own theme switch). |
|
|
@@ -331,7 +331,7 @@ Both methods receive the same arguments:
|
|
|
331
331
|
- `cancelText` (string | null): cancel button text (`Cancel` for confirm, `null` for alert)
|
|
332
332
|
- `okText` (string): confirm/OK button text (default `OK`)
|
|
333
333
|
|
|
334
|
-
The client uses contextual titles such as `Delete Message`, `Validation Error`, `Success`, `Send Error`, and `Download Error`. `confirmMethod` should return a boolean (or a promise for one); `alertMethod` may be sync or async.
|
|
334
|
+
The client uses contextual titles such as `Delete Message`, `Validation Error`, `Success`, `Send Error`, and `Download Error`. `confirmMethod` should return a boolean (or a promise for one); `alertMethod` may be sync or async. When your dialog can be closed without either button (a close button, Escape, a click on the backdrop), have `confirmMethod` return `null` for that: the client then treats the question as unanswered. It matters for "Save the message you are writing as a draft?", whose cancel button discards the message, so a dismissed question keeps the message open instead. The browser's own `confirm()` has no such state, and a host that returns only booleans works as before.
|
|
335
335
|
|
|
336
336
|
## Security
|
|
337
337
|
|
package/index.d.ts
CHANGED
|
@@ -188,7 +188,13 @@ export interface SubmitDraftOptions {
|
|
|
188
188
|
* `(message, title, cancelText, okText)`; `cancelText` is `null` for alerts.
|
|
189
189
|
* May be synchronous or asynchronous. Confirm handlers should resolve to a boolean.
|
|
190
190
|
*/
|
|
191
|
-
|
|
191
|
+
/** A confirm resolves true for the OK button and false for the cancel button. A host dialog closed without either (its close button, Escape, the backdrop) may resolve null: the client then treats the question as unanswered, which keeps an unsaved message open. */
|
|
192
|
+
export type DialogMethod = (
|
|
193
|
+
message: string,
|
|
194
|
+
title?: string,
|
|
195
|
+
cancelText?: string | null,
|
|
196
|
+
okText?: string
|
|
197
|
+
) => boolean | null | void | Promise<boolean | null | void>;
|
|
192
198
|
|
|
193
199
|
export interface EmailEngineClientOptions {
|
|
194
200
|
apiUrl?: string;
|
package/index.js
CHANGED
|
@@ -4100,13 +4100,19 @@ export class EmailEngineClient {
|
|
|
4100
4100
|
}
|
|
4101
4101
|
|
|
4102
4102
|
// Before the form is closed or reused: a changed message is saved as a draft or discarded, as
|
|
4103
|
-
// the user chooses. Resolves false when saving failed, so the
|
|
4103
|
+
// the user chooses. Resolves false when the question was dismissed or saving failed, so the
|
|
4104
|
+
// message stays on screen.
|
|
4104
4105
|
async _settleOpenCompose() {
|
|
4105
4106
|
if (!this._isComposeDirty()) {
|
|
4106
4107
|
return true;
|
|
4107
4108
|
}
|
|
4108
4109
|
this._setComposeMinimized(false);
|
|
4109
4110
|
const save = await this.confirmMethod('Save the message you are writing as a draft?', 'Unsaved message', 'Discard', 'Save draft');
|
|
4111
|
+
// A host dialog closed without either button (its close button, Escape, the backdrop)
|
|
4112
|
+
// answers null, and that is no decision to throw the message away: it stays on screen
|
|
4113
|
+
if (save === null) {
|
|
4114
|
+
return false;
|
|
4115
|
+
}
|
|
4110
4116
|
if (!save) {
|
|
4111
4117
|
return true;
|
|
4112
4118
|
}
|
|
@@ -4790,7 +4796,11 @@ export class EmailEngineClient {
|
|
|
4790
4796
|
this.initialMessage = null;
|
|
4791
4797
|
const message = messageId ? this.loadMessage(messageId).catch(() => null) : Promise.resolve(null);
|
|
4792
4798
|
|
|
4793
|
-
|
|
4799
|
+
// The folders come first without their unread counts: those cost a STATUS command per
|
|
4800
|
+
// folder on the IMAP connection the message and the listing are read over too, so asking
|
|
4801
|
+
// for them up front made the first view wait behind them - seconds on a distant server.
|
|
4802
|
+
// They follow once the view is up.
|
|
4803
|
+
return this.loadFolders({ counters: false })
|
|
4794
4804
|
.catch(error => {
|
|
4795
4805
|
// loadFolders reports into the sidebar, but the message list is the
|
|
4796
4806
|
// larger pane and would still read "Select a folder" - a folder the
|
|
@@ -4800,6 +4810,7 @@ export class EmailEngineClient {
|
|
|
4800
4810
|
})
|
|
4801
4811
|
.then(async () => {
|
|
4802
4812
|
await this._listFolderOf(await message);
|
|
4813
|
+
this._fireAndForget(this._loadFolderCounters());
|
|
4803
4814
|
return true;
|
|
4804
4815
|
})
|
|
4805
4816
|
.catch(error => {
|
|
@@ -4809,6 +4820,20 @@ export class EmailEngineClient {
|
|
|
4809
4820
|
});
|
|
4810
4821
|
}
|
|
4811
4822
|
|
|
4823
|
+
// Fetches the folder list again with unread counts and redraws the folder pane. Without them
|
|
4824
|
+
// the folders still work, so a failure only leaves the counts out.
|
|
4825
|
+
async _loadFolderCounters() {
|
|
4826
|
+
try {
|
|
4827
|
+
await this._fetchFolders(true);
|
|
4828
|
+
} catch (error) {
|
|
4829
|
+
console.warn('Failed to load folder counts:', error);
|
|
4830
|
+
return;
|
|
4831
|
+
}
|
|
4832
|
+
if (this.container && !this._destroyed) {
|
|
4833
|
+
this.renderFolderList();
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
|
|
4812
4837
|
_inboxFolder() {
|
|
4813
4838
|
return (
|
|
4814
4839
|
this.folders.find(f => f.specialUse && f.specialUse.includes('\\Inbox')) ||
|