mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 07:02:26 -05:00
[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'
This commit is contained in:
parent
6934ae378a
commit
6418307c64
11 changed files with 183 additions and 36 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue