web: fix SidebarUser not rendering

This commit is contained in:
Jens Langhammer 2020-12-02 14:45:19 +01:00
parent cc5a0c23aa
commit dc4a7d98e8
1 changed files with 6 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import fa from "@fortawesome/fontawesome-free/css/all.css";
// @ts-ignore // @ts-ignore
import AvatarStyle from "@patternfly/patternfly/components/Avatar/avatar.css"; import AvatarStyle from "@patternfly/patternfly/components/Avatar/avatar.css";
import { User } from "../../api/user"; import { User } from "../../api/user";
import { until } from "lit-html/directives/until";
@customElement("pb-sidebar-user") @customElement("pb-sidebar-user")
export class SidebarUser extends LitElement { export class SidebarUser extends LitElement {
@ -41,12 +42,13 @@ export class SidebarUser extends LitElement {
]; ];
} }
async render(): Promise<TemplateResult> { render(): TemplateResult {
const user = await User.me();
return html` return html`
<a href="#/-/user/" class="pf-c-nav__link user-avatar" id="user-settings"> <a href="#/-/user/" class="pf-c-nav__link user-avatar" id="user-settings">
<img class="pf-c-avatar" src="${user.avatar}" alt="" /> ${until(User.me().then(u => {
<span>${user.username}</span> return html`<img class="pf-c-avatar" src="${u.avatar}" alt="" />
<span>${u.username}</span>`;
}), html``)}
</a> </a>
<a href="/flows/-/default/invalidation/" class="pf-c-nav__link user-logout" id="logout"> <a href="/flows/-/default/invalidation/" class="pf-c-nav__link user-logout" id="logout">
<i class="fas fa-sign-out-alt" aria-hidden="true"></i> <i class="fas fa-sign-out-alt" aria-hidden="true"></i>