mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 04:27:37 +03:00
Make first WebUI random page stick
This commit is contained in:
parent
653b4d97f9
commit
3977ef6e0f
6 changed files with 75 additions and 21 deletions
|
@ -144,9 +144,17 @@ func (r sqlRepository) seededRandomSort() string {
|
|||
}
|
||||
|
||||
func (r sqlRepository) resetSeededRandom(options []model.QueryOptions) {
|
||||
if len(options) > 0 && options[0].Offset == 0 && options[0].Sort == "random" {
|
||||
u, _ := request.UserFrom(r.ctx)
|
||||
hasher.Reseed(r.tableName + u.ID)
|
||||
if len(options) == 0 || options[0].Sort != "random" {
|
||||
return
|
||||
}
|
||||
|
||||
if options[0].Seed != "" {
|
||||
hasher.SetSeed(r.tableName+userId(r.ctx), options[0].Seed)
|
||||
return
|
||||
}
|
||||
|
||||
if options[0].Offset == 0 {
|
||||
hasher.Reseed(r.tableName + userId(r.ctx))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,10 @@ func (r sqlRestful) parseRestOptions(options ...rest.QueryOptions) model.QueryOp
|
|||
qo.Order = strings.ToLower(options[0].Order)
|
||||
qo.Max = options[0].Max
|
||||
qo.Offset = options[0].Offset
|
||||
if seed, ok := options[0].Filters["seed"].(string); ok {
|
||||
qo.Seed = seed
|
||||
delete(options[0].Filters, "seed")
|
||||
}
|
||||
qo.Filters = r.parseRestFilters(options[0])
|
||||
}
|
||||
return qo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue