2 Commits
5.0.2 ... 5.0.3

Author SHA1 Message Date
Laurent Dinclaux
c194661fa3 fix: prevent username flash on load and remove select max-width 2026-05-06 20:11:10 +11:00
Laurent Dinclaux
e539c60e9b feat: use primary identity display name in switcher dropdown
The account switcher dropdown previously showed the IMAP username
(typically the email address) for the primary account. Now it falls
back to the identity's display name when available, matching the
behavior of secondary accounts which use their custom label.

Priority order: global_alias session var > primary identity display
name > IMAP username.
2026-05-06 17:37:50 +11:00
4 changed files with 34 additions and 8 deletions

View File

@@ -67,7 +67,6 @@ function plugin_switchIdent_addCbLarry($wrapper, $sw) {
$sw.css({ $sw.css({
'font-weight': 'bold', 'font-weight': 'bold',
'max-width': '200px',
'text-overflow': 'ellipsis' 'text-overflow': 'ellipsis'
}); });
@@ -104,7 +103,6 @@ function plugin_switchIdent_addCbElastic($wrapper, $sw) {
'font-weight': 'bold', 'font-weight': 'bold',
'color': 'inherit', 'color': 'inherit',
'box-shadow': 'none', 'box-shadow': 'none',
'max-width': '200px',
'text-overflow': 'ellipsis', 'text-overflow': 'ellipsis',
'padding': '0 1.2em 0 0.25em' 'padding': '0 1.2em 0 0.25em'
}); });

View File

@@ -27,6 +27,32 @@
background-size: 10px 6px; background-size: 10px 6px;
} }
/*
* Prevent flash of original username before JS prepends the switcher.
* The JS hides these elements at DOMReady, but the CSS rules below hide them
* earlier (during initial render) — only loaded when the switcher will actually
* be shown, so users without secondary accounts keep the default username display.
*/
/* Elastic skin: switcher is prepended inside .header-title.username.
Hide the original username via visibility on the parent (affects the text
node), then re-show the wrapper. Unlike color/font-size, this preserves the
parent's flex/line-height context, keeping the wrapper vertically centered. */
.header-title.username {
visibility: hidden;
}
.header-title.username > *:not(.ident-switch-wrapper) {
display: none;
}
.header-title.username > .ident-switch-wrapper {
visibility: visible;
}
/* Larry skin: switcher is prepended next to .username inside #topline .topright */
#topline .topright > .username {
display: none;
}
/* Unread badge */ /* Unread badge */
.ident-switch-badge { .ident-switch-badge {
flex-shrink: 0; flex-shrink: 0;

View File

@@ -158,10 +158,6 @@ class ident_switch extends rcube_plugin
default => null, default => null,
}; };
if ($rc->task === 'mail') {
$this->include_stylesheet('ident_switch.css');
}
return $args; return $args;
} }
@@ -188,7 +184,9 @@ class ident_switch extends rcube_plugin
$iid = intval($iid_s); $iid = intval($iid_s);
} }
$accNames = [$_SESSION['global_alias'] ?? $rc->user->data['username']]; $primaryIdentity = $rc->user->get_identity();
$primaryName = !empty($primaryIdentity['name']) ? $primaryIdentity['name'] : null;
$accNames = [$_SESSION['global_alias'] ?? $primaryName ?? $rc->user->data['username']];
$accValues = [-1]; $accValues = [-1];
$accSelected = -1; $accSelected = -1;
$iidMap = [0 => -1]; // primary account: iid 0 → select value -1 $iidMap = [0 => -1]; // primary account: iid 0 → select value -1
@@ -216,6 +214,7 @@ class ident_switch extends rcube_plugin
return; return;
} }
$this->include_stylesheet('ident_switch.css');
$this->include_script('ident_switch-switch.js'); $this->include_script('ident_switch-switch.js');
// Pass config to JS environment // Pass config to JS environment

View File

@@ -177,6 +177,9 @@ class IdentSwitchChecker
$host = 'tls://' . $host; $host = 'tls://' . $host;
} }
$primaryIdentity = $rc->user->get_identity();
$primaryName = !empty($primaryIdentity['name']) ? $primaryIdentity['name'] : null;
return [ return [
'iid' => 0, 'iid' => 0,
'imap_host' => $host, 'imap_host' => $host,
@@ -185,7 +188,7 @@ class IdentSwitchChecker
'username' => $rc->user->data['username'], 'username' => $rc->user->data['username'],
'password' => $_SESSION['password' . $postfix], 'password' => $_SESSION['password' . $postfix],
'email' => $rc->user->data['username'], 'email' => $rc->user->data['username'],
'label' => $_SESSION['global_alias'] ?? $rc->user->data['username'], 'label' => $_SESSION['global_alias'] ?? $primaryName ?? $rc->user->data['username'],
'notify_basic' => null, 'notify_basic' => null,
'notify_sound' => null, 'notify_sound' => null,
'notify_desktop' => null, 'notify_desktop' => null,