Fix album browser not respecting cover provider

This commit is contained in:
Ming Ming 2021-08-13 18:41:02 +08:00
parent 06c797a736
commit b1d37f7b73
3 changed files with 9 additions and 8 deletions

View file

@ -163,7 +163,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
setState(() {
_album = album;
_transformItems();
initCover(widget.account, _backingFiles);
initCover(widget.account, album);
});
}
});
@ -321,7 +321,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
setState(() {
_album = newAlbum;
_transformItems();
initCover(widget.account, _backingFiles);
initCover(widget.account, newAlbum);
});
}).catchError((e, stacktrace) {
_log.shout("[_onSelectionRemovePressed] Failed while updating album", e,

View file

@ -23,13 +23,14 @@ mixin AlbumBrowserMixin<T extends StatefulWidget>
}
@protected
void initCover(Account account, List<File> backingFiles) {
void initCover(Account account, Album album) {
try {
final coverFile =
backingFiles.firstWhere((element) => element.hasPreview ?? false);
_coverPreviewUrl = api_util.getFilePreviewUrl(account, coverFile,
final coverFile = album.coverProvider.getCover(album);
_coverPreviewUrl = api_util.getFilePreviewUrl(account, coverFile!,
width: 1024, height: 600);
} catch (_) {}
} catch (_) {
return null;
}
}
@protected

View file

@ -150,7 +150,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
setState(() {
_album = widget.album;
_transformItems(items);
initCover(widget.account, _backingFiles);
initCover(widget.account, widget.album);
_updateAlbumPostPopulate(items);
});
}