smaller batch sizes to make search results appear faster
This commit is contained in:
+13
-7
@@ -11,6 +11,8 @@ import (
|
|||||||
"github.com/dweymouth/go-subsonic"
|
"github.com/dweymouth/go-subsonic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const albumFetchBatchSize = 6
|
||||||
|
|
||||||
type ImageFetcher interface {
|
type ImageFetcher interface {
|
||||||
GetAlbumThumbnailFromCache(string) (image.Image, bool)
|
GetAlbumThumbnailFromCache(string) (image.Image, bool)
|
||||||
GetAlbumThumbnail(string) (image.Image, error)
|
GetAlbumThumbnail(string) (image.Image, error)
|
||||||
@@ -181,15 +183,19 @@ func (a *AlbumGrid) fetchMoreAlbums(count int) {
|
|||||||
}
|
}
|
||||||
a.fetching = true
|
a.fetching = true
|
||||||
go func() {
|
go func() {
|
||||||
albums := a.iter.NextN(count)
|
n := 0
|
||||||
a.albums = append(a.albums, albums...)
|
for !a.done && n < count {
|
||||||
if len(albums) < count {
|
albums := a.iter.NextN(albumFetchBatchSize)
|
||||||
a.done = true
|
a.albums = append(a.albums, albums...)
|
||||||
|
if len(albums) < albumFetchBatchSize {
|
||||||
|
a.done = true
|
||||||
|
}
|
||||||
|
n += len(albums)
|
||||||
|
if len(albums) > 0 {
|
||||||
|
a.Refresh()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
a.fetching = false
|
a.fetching = false
|
||||||
if len(albums) > 0 {
|
|
||||||
a.Refresh()
|
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user