fix: broken avatar

pull/934/head
Tienson Qin 2020-12-17 15:32:12 +08:00
parent f768744380
commit 31a8498e3c
2 changed files with 62 additions and 57 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -15,7 +15,9 @@
[frontend.components.repo :as repo]
[frontend.components.search :as search]
[frontend.handler.project :as project-handler]
[frontend.handler.web.nfs :as nfs]))
[frontend.handler.web.nfs :as nfs]
[goog.dom :as gdom]
[goog.object :as gobj]))
(rum/defc logo < rum/reactive
[{:keys [white?]}]
@ -49,8 +51,11 @@
[:button.max-w-xs.flex.items-center.text-sm.rounded-full.focus:outline-none.focus:shadow-outline.h-7.w-7.ml-2
{:on-click toggle-fn}
(if-let [avatar (:avatar me)]
[:img.h-7.w-7.rounded-full
{:src avatar}]
[:img#avatar.h-7.w-7.rounded-full
{:src avatar
:on-error (fn [this]
(let [elem (gdom/getElement "avatar")]
(gobj/set elem "src" (config/asset-uri "/static/img/broken-avatar.png"))))}]
[:div.h-7.w-7.rounded-full.bg-base-2.opacity-70.hover:opacity-100 {:style {:padding 1.5}}
[:a svg/user]])])
(let [logged? (:name me)]