Signed-off-by: oppiliappan me@oppi.li
+69
Diff
round #0
+18
appview/pages/pages.go
+18
appview/pages/pages.go
···
768
768
return p.executePlain("user/fragments/follow-oob", w, params)
769
769
}
770
770
771
+
type ProfilePopoverParams struct {
772
+
LoggedInUser *oauth.MultiAccountUser
773
+
UserDid string
774
+
Profile *models.Profile
775
+
FollowStatus models.FollowStatus
776
+
VouchRelationship *models.VouchRelationship
777
+
Stats ProfilePopoverStats
778
+
}
779
+
780
+
type ProfilePopoverStats struct {
781
+
FollowersCount int64
782
+
FollowingCount int64
783
+
}
784
+
785
+
func (p *Pages) ProfilePopoverFragment(w io.Writer, params ProfilePopoverParams) error {
786
+
return p.executePlain("user/fragments/profilePopover", w, params)
787
+
}
788
+
771
789
type EditBioParams struct {
772
790
LoggedInUser *oauth.MultiAccountUser
773
791
Profile *models.Profile
+49
appview/state/profile.go
+49
appview/state/profile.go
···
905
905
s.pages.HxRedirect(w, "/"+user.Did)
906
906
}
907
907
908
+
func (s *State) ProfilePopover(w http.ResponseWriter, r *http.Request) {
909
+
l := s.logger.With("handler", "ProfilePopover")
910
+
911
+
did := r.URL.Query().Get("did")
912
+
if did == "" {
913
+
l.Warn("missing did param")
914
+
w.WriteHeader(http.StatusBadRequest)
915
+
return
916
+
}
917
+
918
+
profile, err := db.GetProfile(s.db, did)
919
+
if err != nil {
920
+
l.Error("failed to get profile", "did", did, "err", err)
921
+
w.WriteHeader(http.StatusInternalServerError)
922
+
return
923
+
}
924
+
if profile == nil {
925
+
profile = &models.Profile{Did: did}
926
+
}
927
+
928
+
followStats, err := db.GetFollowerFollowingCount(s.db, did)
929
+
if err != nil {
930
+
l.Error("failed to get follower stats", "did", did, "err", err)
931
+
w.WriteHeader(http.StatusInternalServerError)
932
+
return
933
+
}
934
+
935
+
loggedInUser := s.oauth.GetMultiAccountUser(r)
936
+
followStatus := models.IsNotFollowing
937
+
var vouchRelationship *models.VouchRelationship
938
+
939
+
if loggedInUser != nil {
940
+
followStatus = db.GetFollowStatus(s.db, loggedInUser.Did, did)
941
+
vouchRelationship, _ = db.GetVouchRelationship(s.db, syntax.DID(loggedInUser.Did), syntax.DID(did))
942
+
}
943
+
944
+
s.pages.ProfilePopoverFragment(w, pages.ProfilePopoverParams{
945
+
LoggedInUser: loggedInUser,
946
+
UserDid: did,
947
+
Profile: profile,
948
+
FollowStatus: followStatus,
949
+
VouchRelationship: vouchRelationship,
950
+
Stats: pages.ProfilePopoverStats{
951
+
FollowersCount: followStats.Followers,
952
+
FollowingCount: followStats.Following,
953
+
},
954
+
})
955
+
}
956
+
908
957
func (s *State) EditBioFragment(w http.ResponseWriter, r *http.Request) {
909
958
l := s.logger.With("handler", "EditBioFragment")
910
959
user := s.oauth.GetMultiAccountUser(r)
History
1 round
0 comments
oppi.li
submitted
#0
1 commit
expand
collapse
appview/state: add htmx handler for profile popups
Signed-off-by: oppiliappan <me@oppi.li>
merge conflicts detected
expand
collapse
expand
collapse
- appview/pages/templates/repo/issues/fragments/issueListing.html:1
- appview/pages/templates/repo/pulls/pull.html:136