diff --git a/static/js/emailLibrary.js b/static/js/emailLibrary.js
index b7d4504da..b1883eb21 100644
--- a/static/js/emailLibrary.js
+++ b/static/js/emailLibrary.js
@@ -1330,11 +1330,20 @@ function _renderAccountsStrip() {
strip.style.display = 'flex';
const esc = s => String(s || '').replace(/&/g, '&').replace(/All (default)`;
+ // 'Default' rather than 'All (default)' — this view shows the account
+ // marked is_default; cross-account aggregation is a separate feature.
+ let html = ``;
+ const _starFilled = '';
+ const _starHollow = '';
for (const a of state._libAccounts) {
const active = state._libAccountId === a.id ? ' active' : '';
const label = a.name || a.from_address || a.imap_user || 'account';
- html += ``;
+ const star = a.is_default ? _starFilled : _starHollow;
+ const starTitle = a.is_default ? 'Default account' : 'Set as default';
+ html += ``
+ + ``
+ + ``
+ + ``;
}
strip.innerHTML = html;
strip.querySelectorAll('button[data-acc-id]').forEach(btn => {
@@ -1347,6 +1356,25 @@ function _renderAccountsStrip() {
_loadEmails({ force: true, useCache: false });
});
});
+ // Star handler: POST set-default, then reload accounts + re-render so
+ // the chip stars reflect the new default.
+ strip.querySelectorAll('button[data-set-default]').forEach(btn => {
+ btn.addEventListener('click', async (e) => {
+ e.stopPropagation();
+ const acctId = btn.dataset.setDefault;
+ if (!acctId) return;
+ try {
+ await fetch(`${API_BASE}/api/email/accounts/${encodeURIComponent(acctId)}/set-default`, {
+ method: 'POST', credentials: 'same-origin',
+ });
+ // Refresh the local accounts cache and re-render the strip.
+ for (const a of state._libAccounts) a.is_default = (a.id === acctId);
+ _renderAccountsStrip();
+ } catch (err) {
+ console.error('Set default account failed:', err);
+ }
+ });
+ });
// Idempotent — wire wheel + grab-drag scroll once per strip element.
if (!strip._scrollWired) {
strip._scrollWired = true;