diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a4376e2a..fa9e26211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. ### Fixed - wrong window metrics on startup in some cases +- home albums not updated on startup in some cases ## [v1.6.7] - 2022-05-25 diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/MainActivity.kt b/android/app/src/main/kotlin/deckers/thibault/aves/MainActivity.kt index 203021676..e1b78809a 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/MainActivity.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/MainActivity.kt @@ -130,7 +130,7 @@ class MainActivity : FlutterActivity() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { Handler(Looper.getMainLooper()).postDelayed({ window.decorView.requestApplyInsets() - }, 10) + }, 100) } } diff --git a/lib/model/source/album.dart b/lib/model/source/album.dart index 1fd58d204..4eedac52b 100644 --- a/lib/model/source/album.dart +++ b/lib/model/source/album.dart @@ -26,10 +26,14 @@ mixin AlbumMixin on SourceBase { return compareAsciiUpperCase(va, vb); } + void notifyAlbumsChanged() { + eventBus.fire(AlbumsChangedEvent()); + } + void _onAlbumChanged({bool notify = true}) { invalidateAlbumDisplayNames(); if (notify) { - eventBus.fire(AlbumsChangedEvent()); + notifyAlbumsChanged(); } } diff --git a/lib/model/source/media_store_source.dart b/lib/model/source/media_store_source.dart index 8bd93063f..28fbc4b76 100644 --- a/lib/model/source/media_store_source.dart +++ b/lib/model/source/media_store_source.dart @@ -184,6 +184,11 @@ class MediaStoreSource extends CollectionSource { } await analyze(analysisController, entries: analysisEntries); + // the home page may not reflect the current derived filters + // as the initial addition of entries is silent, + // so we manually notify change for potential home screen filters + notifyAlbumsChanged(); + debugPrint('$runtimeType refresh ${stopwatch.elapsed} done for ${knownEntries.length} known, ${allNewEntries.length} new, ${removedEntries.length} removed'); }, onError: (error) => debugPrint('$runtimeType stream error=$error'), diff --git a/lib/widgets/filter_grids/albums_page.dart b/lib/widgets/filter_grids/albums_page.dart index 9ebb50c89..fec6279e6 100644 --- a/lib/widgets/filter_grids/albums_page.dart +++ b/lib/widgets/filter_grids/albums_page.dart @@ -35,29 +35,31 @@ class AlbumListPage extends StatelessWidget { builder: (context, s, child) { return ValueListenableBuilder( valueListenable: androidFileUtils.areAppNamesReadyNotifier, - builder: (context, areAppNamesReady, child) => StreamBuilder( - stream: source.eventBus.on(), - builder: (context, snapshot) { - final gridItems = getAlbumGridItems(context, source); - return StreamBuilder?>( - // to update sections by tier - stream: covers.packageChangeStream, - builder: (context, snapshot) => FilterNavigationPage( - source: source, - title: context.l10n.albumPageTitle, - sortFactor: settings.albumSortFactor, - showHeaders: settings.albumGroupFactor != AlbumChipGroupFactor.none, - actionDelegate: AlbumChipSetActionDelegate(gridItems), - filterSections: groupToSections(context, source, gridItems), - newFilters: source.getNewAlbumFilters(context), - emptyBuilder: () => EmptyContent( - icon: AIcons.album, - text: context.l10n.albumEmpty, + builder: (context, areAppNamesReady, child) { + return StreamBuilder( + stream: source.eventBus.on(), + builder: (context, snapshot) { + final gridItems = getAlbumGridItems(context, source); + return StreamBuilder?>( + // to update sections by tier + stream: covers.packageChangeStream, + builder: (context, snapshot) => FilterNavigationPage( + source: source, + title: context.l10n.albumPageTitle, + sortFactor: settings.albumSortFactor, + showHeaders: settings.albumGroupFactor != AlbumChipGroupFactor.none, + actionDelegate: AlbumChipSetActionDelegate(gridItems), + filterSections: groupToSections(context, source, gridItems), + newFilters: source.getNewAlbumFilters(context), + emptyBuilder: () => EmptyContent( + icon: AIcons.album, + text: context.l10n.albumEmpty, + ), ), - ), - ); - }, - ), + ); + }, + ); + }, ); }, );