From a68a09a83ef2eb411e2a7a66e919f27c040c0b6a Mon Sep 17 00:00:00 2001 From: r Date: Sat, 8 Feb 2020 11:50:14 +0000 Subject: [PATCH] Remove account relationship buttons for logged in user's page --- renderer/model.go | 22 ++++++++++++++++------ service/service.go | 1 + templates/user.tmpl | 2 ++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/renderer/model.go b/renderer/model.go index 4ff73c3..842dd71 100644 --- a/renderer/model.go +++ b/renderer/model.go @@ -31,6 +31,15 @@ type CommonData struct { NavbarData *NavbarData } +func (c CommonData) IsCurrentUser(id string) bool { + if c.NavbarData != nil && + c.NavbarData.User != nil && + c.NavbarData.User.ID == id { + return true + } + return false +} + type ErrorData struct { *CommonData Error string @@ -69,12 +78,13 @@ type NotificationData struct { type UserData struct { *CommonData - User *mastodon.Account - Type string - Users []*mastodon.Account - Statuses []*mastodon.Status - NextLink string - DarkMode bool + User *mastodon.Account + IsCurrent bool + Type string + Users []*mastodon.Account + Statuses []*mastodon.Status + NextLink string + DarkMode bool } type UserSearchData struct { diff --git a/service/service.go b/service/service.go index c05097b..d762842 100644 --- a/service/service.go +++ b/service/service.go @@ -527,6 +527,7 @@ func (svc *service) ServeUserPage(ctx context.Context, c *model.Client, data := &renderer.UserData{ User: user, + IsCurrent: commonData.IsCurrentUser(user.ID), Type: pageType, Users: users, Statuses: statuses, diff --git a/templates/user.tmpl b/templates/user.tmpl index fb80de4..60d766b 100644 --- a/templates/user.tmpl +++ b/templates/user.tmpl @@ -18,6 +18,7 @@ source + {{if not .IsCurrent}}
{{if .User.Pleroma.Relationship.FollowedBy}} follows you - {{end}} {{if .User.Pleroma.Relationship.Following}} @@ -64,6 +65,7 @@ {{end}}
+ {{end}}
statuses ({{.User.StatusesCount}}) - following ({{.User.FollowingCount}}) -