mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 18:22:26 -05:00 
			
		
		
		
	[chore] much improved paging package (#2182)
This commit is contained in:
		
					parent
					
						
							
								14ef098099
							
						
					
				
			
			
				commit
				
					
						b093947d84
					
				
			
		
					 15 changed files with 1154 additions and 445 deletions
				
			
		|  | @ -34,11 +34,11 @@ import ( | |||
| func (p *Processor) BlocksGet( | ||||
| 	ctx context.Context, | ||||
| 	requestingAccount *gtsmodel.Account, | ||||
| 	page paging.Pager, | ||||
| 	page *paging.Page, | ||||
| ) (*apimodel.PageableResponse, gtserror.WithCode) { | ||||
| 	blocks, err := p.state.DB.GetAccountBlocks(ctx, | ||||
| 		requestingAccount.ID, | ||||
| 		&page, | ||||
| 		page, | ||||
| 	) | ||||
| 	if err != nil && !errors.Is(err, db.ErrNoEntries) { | ||||
| 		return nil, gtserror.NewErrorInternalError(err) | ||||
|  | @ -77,13 +77,10 @@ func (p *Processor) BlocksGet( | |||
| 		items = append(items, account) | ||||
| 	} | ||||
| 
 | ||||
| 	return util.PackagePageableResponse(util.PageableResponseParams{ | ||||
| 		Items:          items, | ||||
| 		Path:           "/api/v1/blocks", | ||||
| 		NextMaxIDKey:   "max_id", | ||||
| 		PrevMinIDKey:   "since_id", | ||||
| 		NextMaxIDValue: nextMaxIDValue, | ||||
| 		PrevMinIDValue: prevMinIDValue, | ||||
| 		Limit:          page.Limit, | ||||
| 	}) | ||||
| 	return paging.PackageResponse(paging.ResponseParams{ | ||||
| 		Items: items, | ||||
| 		Path:  "/api/v1/blocks", | ||||
| 		Next:  page.Next(nextMaxIDValue), | ||||
| 		Prev:  page.Prev(prevMinIDValue), | ||||
| 	}), nil | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue