honor dlna sort order to content exceeding the first page (#3747)

This commit is contained in:
CJ 2023-05-23 00:07:06 -05:00 committed by GitHub
parent 124adb3f5b
commit 58a6c22072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 10 deletions

View file

@ -440,15 +440,21 @@ func getRootObjects() []interface{} {
return objs
}
func getSortDirection(sceneFilter *models.SceneFilterType, sort string) models.SortDirectionEnum {
direction := models.SortDirectionEnumDesc
if sort == "title" {
direction = models.SortDirectionEnumAsc
}
return direction
}
func (me *contentDirectoryService) getVideos(sceneFilter *models.SceneFilterType, parentID string, host string) []interface{} {
var objs []interface{}
if err := txn.WithReadTxn(context.TODO(), me.txnManager, func(ctx context.Context) error {
sort := me.VideoSortOrder
direction := models.SortDirectionEnumDesc
if sort == "title" {
direction = models.SortDirectionEnumAsc
}
direction := getSortDirection(sceneFilter, sort)
findFilter := &models.FindFilterType{
PerPage: &pageSize,
Sort: &sort,
@ -497,8 +503,10 @@ func (me *contentDirectoryService) getPageVideos(sceneFilter *models.SceneFilter
parentID: parentID,
}
sort := me.VideoSortOrder
direction := getSortDirection(sceneFilter, sort)
var err error
objs, err = pager.getPageVideos(ctx, me.repository.SceneFinder, me.repository.FileFinder, page, host)
objs, err = pager.getPageVideos(ctx, me.repository.SceneFinder, me.repository.FileFinder, page, host, sort, direction)
if err != nil {
return err
}

View file

@ -60,14 +60,14 @@ func (p *scenePager) getPages(ctx context.Context, r scene.Queryer, total int) (
return objs, nil
}
func (p *scenePager) getPageVideos(ctx context.Context, r SceneFinder, f file.Finder, page int, host string) ([]interface{}, error) {
func (p *scenePager) getPageVideos(ctx context.Context, r SceneFinder, f file.Finder, page int, host string, sort string, direction models.SortDirectionEnum) ([]interface{}, error) {
var objs []interface{}
sort := "title"
findFilter := &models.FindFilterType{
PerPage: &pageSize,
Page: &page,
Sort: &sort,
Direction: &direction,
}
scenes, err := scene.Query(ctx, r, p.sceneFilter, findFilter)