diff --git a/repl-sessions/participants.clj b/repl-sessions/participants.clj index f53dc31..56401dd 100644 --- a/repl-sessions/participants.clj +++ b/repl-sessions/participants.clj @@ -11,6 +11,19 @@ [co.gaiwan.compass.model.assets :as assets] [datomic.api :as d])) +(defn test-user-eid + "Query the database to find out a certain login by discord user" + [user-name] + (db/q + '[:find ?e . + :in $ ?u + :where + [?e :public-profile/name ?u]] + (db/db) user-name)) + +(def user-eid + (test-user-eid "Laurence")) + (def new-session-eid 17592186045455) ;; Avatar source URL https://github.com/alohe/avatars @@ -27,9 +40,13 @@ (fn [x] {:db/id (str "temp-" x) :user/uuid (random-uuid) + :user/contacts user-eid :discord/email (str "temp-email-" x "@gaiwan.co") :public-profile/hidden? (if (even? x) true false) :public-profile/name (str "temp-user-" x) + :public-profile/bio "problic-bio" + :private-profile/bio "private-bio" + :private-profile/name "private-name" :public-profile/avatar-url (assets/download-image (str avatar-url-part x ".png"))}) (range 1 11)) ;; Below is for session join diff --git a/src/co/gaiwan/compass/html/profiles.clj b/src/co/gaiwan/compass/html/profiles.clj index 64ef359..2962e0a 100644 --- a/src/co/gaiwan/compass/html/profiles.clj +++ b/src/co/gaiwan/compass/html/profiles.clj @@ -24,22 +24,35 @@ [:.link :w-full :flex :flex-1 :py-1 :font-size-3] [:.link-type :w-12 :px-2] [:.link-ref :flex-grow :px-2]] - + [:.contact-card :my-2] ([{:public-profile/keys [name hidden?] :user/keys [uuid] :as user} viewer] [:<> [:div [c/image-frame {:profile/image (user/avatar-css-value user)}]] [:div.details [:h3.title name] - [:div.bio - (m/component (m/md->hiccup (:public-profile/bio user)))] + (when (:public-profile/bio user) + [:div.bio + (m/component (m/md->hiccup (:public-profile/bio user)))]) [:div.links (for [link (:public-profile/links user)] [:div.link [:div.link-type (:profile-link/type link)] [:div.link-ref (:profile-link/href link)]])]] - -;; hide edit button unless it's your own profile + ;; if the user is connected (contact), show "contact card" + (when (some #{(:db/id viewer)} (map :db/id (:user/contacts user))) + [:div.contact-card + [:div.details + [:h3.title (:private-profile/name user)] + (when (:private-profile/bio user) + [:div.bio + (m/component (m/md->hiccup (:private-profile/bio user)))]) + [:div.links + (for [link (:private-profile/links user)] + [:div.link + [:div.link-type (:profile-link/type link)] + [:div.link-ref (:profile-link/href link)]])]]]) + ;; hide edit button unless it's your own profile (when (= (:db/id viewer) (:db/id user)) [:div.actions [edit-profile-btn user]])]))