summaryrefslogtreecommitdiff
path: root/internal/web/profile.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-07-13 09:57:47 +0200
committerLibravatar GitHub <noreply@github.com>2022-07-13 09:57:47 +0200
commit6418307c64da236a0268f4496f793d982e128ad0 (patch)
tree9c781c812697412936d671e0e42272dce8cf2d78 /internal/web/profile.go
parent[chore] improved router logging, recovery and error handling (#705) (diff)
downloadgotosocial-6418307c64da236a0268f4496f793d982e128ad0.tar.xz
[feature] Add back/next buttons to profiles for paging through statuses (#708)
* add GetAccountWebStatuses to db * add WebStatusesGet func to processor * don't add limit to next/prev links if 0 * take query params for next/prev statuses * add separate next + prev links for convenience * show 'nothing here' message if no statuses exist * add back / next links to profiles * allow paging down only * go fmt ./... * 'recent public toots' -> 'latest public toots'
Diffstat (limited to 'internal/web/profile.go')
-rw-r--r--internal/web/profile.go29
1 files changed, 22 insertions, 7 deletions
diff --git a/internal/web/profile.go b/internal/web/profile.go
index ce3fe645b..542c015f1 100644
--- a/internal/web/profile.go
+++ b/internal/web/profile.go
@@ -36,6 +36,11 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
+const (
+ // MaxStatusIDKey is for specifying the maximum ID of the status to retrieve.
+ MaxStatusIDKey = "max_id"
+)
+
func (m *Module) profileGETHandler(c *gin.Context) {
ctx := c.Request.Context()
@@ -78,10 +83,18 @@ func (m *Module) profileGETHandler(c *gin.Context) {
return
}
- // get latest 10 top-level public statuses;
- // ie., exclude replies and boosts, public only,
- // with or without media
- statusResp, errWithCode := m.processor.AccountStatusesGet(ctx, authed, account.ID, 10, true, true, "", "", false, false, true)
+ // we should only show the 'back to top' button if the
+ // profile visitor is paging through statuses
+ showBackToTop := false
+
+ maxStatusID := ""
+ maxStatusIDString := c.Query(MaxStatusIDKey)
+ if maxStatusIDString != "" {
+ maxStatusID = maxStatusIDString
+ showBackToTop = true
+ }
+
+ statusResp, errWithCode := m.processor.AccountWebStatusesGet(ctx, account.ID, maxStatusID)
if errWithCode != nil {
api.ErrorHandler(c, errWithCode, instanceGet)
return
@@ -103,9 +116,11 @@ func (m *Module) profileGETHandler(c *gin.Context) {
}
c.HTML(http.StatusOK, "profile.tmpl", gin.H{
- "instance": instance,
- "account": account,
- "statuses": statusResp.Items,
+ "instance": instance,
+ "account": account,
+ "statuses": statusResp.Items,
+ "statuses_next": statusResp.NextLink,
+ "show_back_to_top": showBackToTop,
"stylesheets": []string{
"/assets/Fork-Awesome/css/fork-awesome.min.css",
"/assets/dist/status.css",