Added view pinned statuses in accounts

This commit is contained in:
localhost_frssoft 2022-10-26 00:44:22 +03:00
parent b07793e986
commit ca99d0a789
3 changed files with 23 additions and 4 deletions

View File

@ -152,10 +152,11 @@ func (c *Client) AccountUpdate(ctx context.Context, profile *Profile) (*Account,
} }
// GetAccountStatuses return statuses by specified accuont. // GetAccountStatuses return statuses by specified accuont.
func (c *Client) GetAccountStatuses(ctx context.Context, id string, onlyMedia bool, pg *Pagination) ([]*Status, error) { func (c *Client) GetAccountStatuses(ctx context.Context, id string, onlyMedia bool, onlyPinned bool, pg *Pagination) ([]*Status, error) {
var statuses []*Status var statuses []*Status
params := url.Values{} params := url.Values{}
params.Set("only_media", strconv.FormatBool(onlyMedia)) params.Set("only_media", strconv.FormatBool(onlyMedia))
params.Set("pinned", strconv.FormatBool(onlyPinned))
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/accounts/%s/statuses", url.PathEscape(string(id))), params, &statuses, pg) err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/accounts/%s/statuses", url.PathEscape(string(id))), params, &statuses, pg)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -610,7 +610,7 @@ func (s *service) UserPage(c *client, id string, pageType string,
switch pageType { switch pageType {
case "": case "":
statuses, err = c.GetAccountStatuses(c.ctx, id, false, &pg) statuses, err = c.GetAccountStatuses(c.ctx, id, false, false, &pg)
if err != nil { if err != nil {
return return
} }
@ -637,7 +637,7 @@ func (s *service) UserPage(c *client, id string, pageType string,
id, pg.MaxID) id, pg.MaxID)
} }
case "media": case "media":
statuses, err = c.GetAccountStatuses(c.ctx, id, true, &pg) statuses, err = c.GetAccountStatuses(c.ctx, id, true, false, &pg)
if err != nil { if err != nil {
return return
} }
@ -645,6 +645,15 @@ func (s *service) UserPage(c *client, id string, pageType string,
nextLink = fmt.Sprintf("/user/%s/media?max_id=%s", nextLink = fmt.Sprintf("/user/%s/media?max_id=%s",
id, pg.MaxID) id, pg.MaxID)
} }
case "pinned":
statuses, err = c.GetAccountStatuses(c.ctx, id, false, true, &pg)
if err != nil {
return
}
if len(statuses) == 20 && len(pg.MaxID) > 0 {
nextLink = fmt.Sprintf("/user/%s/pinned?max_id=%s",
id, pg.MaxID)
}
case "bookmarks": case "bookmarks":
if !isCurrent { if !isCurrent {
return errInvalidArgument return errInvalidArgument

View File

@ -115,7 +115,8 @@
<a href="/user/{{.User.ID}}"> statuses ({{.User.StatusesCount}}) </a> - <a href="/user/{{.User.ID}}"> statuses ({{.User.StatusesCount}}) </a> -
<a href="/user/{{.User.ID}}/following"> following ({{.User.FollowingCount}}) </a> - <a href="/user/{{.User.ID}}/following"> following ({{.User.FollowingCount}}) </a> -
<a href="/user/{{.User.ID}}/followers"> followers ({{.User.FollowersCount}}) </a> - <a href="/user/{{.User.ID}}/followers"> followers ({{.User.FollowersCount}}) </a> -
<a href="/user/{{.User.ID}}/media"> media </a> <a href="/user/{{.User.ID}}/media"> media </a> -
<a href="/user/{{.User.ID}}/pinned"> pinned statuses </a>
</div> </div>
{{if .IsCurrent}} {{if .IsCurrent}}
<div> <div>
@ -173,6 +174,14 @@
<div class="no-data-found">No data found</div> <div class="no-data-found">No data found</div>
{{end}} {{end}}
{{else if eq .Type "pinned"}}
<div class="page-title"> Pinned statuses </div>
{{range .Statuses}}
{{template "status.tmpl" (WithContext . $.Ctx)}}
{{else}}
<div class="no-data-found">No data found</div>
{{end}}
{{else if eq .Type "bookmarks"}} {{else if eq .Type "bookmarks"}}
<div class="page-title"> Bookmarks </div> <div class="page-title"> Bookmarks </div>
{{range .Statuses}} {{range .Statuses}}