feat: add plugin ui.rerenderEmail API and restyle read-receipt banner

This commit is contained in:
Linus Rath
2026-07-09 16:04:33 +02:00
parent 5ccba83129
commit d3f77ef9cf
6 changed files with 73 additions and 34 deletions
+9
View File
@@ -56,6 +56,7 @@ const PERM_PER_METHOD: Record<string, Permission | null> = {
'ui.confirm': null,
'ui.alert': null,
'ui.prompt': null,
'ui.rerenderEmail': null,
'ui.openExternalUrl': null,
};
@@ -410,6 +411,14 @@ export async function dispatchApiCall(
fields,
});
}
case 'ui.rerenderEmail': {
// Re-run the onRenderEmailBody hook for the currently open message. Used
// by crypto plugins after they change decryption state (e.g. an S/MIME key
// was just unlocked) so the body re-decrypts without a full reload — which
// would wipe the in-memory session keys.
window.dispatchEvent(new CustomEvent('plugin:rerender-email'));
return undefined;
}
case 'ui.openExternalUrl': {
const url = String(args[0] ?? '');
// Only http(s) - the sandbox should not be able to navigate the host
+1 -1
View File
@@ -244,7 +244,7 @@ export const API_METHODS = [
'jmap.fetchBlob', 'jmap.sendRaw',
'admin.getConfig', 'admin.getAllConfig', 'admin.setConfig', 'admin.deleteConfig',
'toast.success', 'toast.error', 'toast.info', 'toast.warning',
'ui.confirm', 'ui.alert', 'ui.prompt', 'ui.openExternalUrl',
'ui.confirm', 'ui.alert', 'ui.prompt', 'ui.rerenderEmail', 'ui.openExternalUrl',
] as const;
export type ApiMethod = (typeof API_METHODS)[number];
+3
View File
@@ -223,6 +223,9 @@ function buildPluginApi(manifest: PluginManifest) {
cancelLabel?: string;
fields?: Array<{ name: string; label: string; type?: 'text' | 'password'; placeholder?: string; required?: boolean }>;
}) => callApi('ui.prompt', [opts], 0) as Promise<Record<string, string> | null>,
/** Re-runs the onRenderEmailBody hook for the open message (e.g. after a
* crypto plugin unlocks a key) so its body re-renders without a reload. */
rerenderEmail: () => callApi('ui.rerenderEmail', []) as Promise<void>,
/** Opens an http/https URL in a new tab via host `window.open`. */
openExternalUrl: (url: string, target?: string) =>
callApi('ui.openExternalUrl', [url, target]) as Promise<void>,