#259 fixed home albums not updated on startup race condition

This commit is contained in:
Thibault Deckers 2022-05-27 12:42:02 +09:00
parent 431b0e7b13
commit a3436bfdf3
5 changed files with 36 additions and 24 deletions

View file

@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
### Fixed ### Fixed
- wrong window metrics on startup in some cases - wrong window metrics on startup in some cases
- home albums not updated on startup in some cases
## <a id="v1.6.7"></a>[v1.6.7] - 2022-05-25 ## <a id="v1.6.7"></a>[v1.6.7] - 2022-05-25

View file

@ -130,7 +130,7 @@ class MainActivity : FlutterActivity() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
Handler(Looper.getMainLooper()).postDelayed({ Handler(Looper.getMainLooper()).postDelayed({
window.decorView.requestApplyInsets() window.decorView.requestApplyInsets()
}, 10) }, 100)
} }
} }

View file

@ -26,10 +26,14 @@ mixin AlbumMixin on SourceBase {
return compareAsciiUpperCase(va, vb); return compareAsciiUpperCase(va, vb);
} }
void notifyAlbumsChanged() {
eventBus.fire(AlbumsChangedEvent());
}
void _onAlbumChanged({bool notify = true}) { void _onAlbumChanged({bool notify = true}) {
invalidateAlbumDisplayNames(); invalidateAlbumDisplayNames();
if (notify) { if (notify) {
eventBus.fire(AlbumsChangedEvent()); notifyAlbumsChanged();
} }
} }

View file

@ -184,6 +184,11 @@ class MediaStoreSource extends CollectionSource {
} }
await analyze(analysisController, entries: analysisEntries); 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'); debugPrint('$runtimeType refresh ${stopwatch.elapsed} done for ${knownEntries.length} known, ${allNewEntries.length} new, ${removedEntries.length} removed');
}, },
onError: (error) => debugPrint('$runtimeType stream error=$error'), onError: (error) => debugPrint('$runtimeType stream error=$error'),

View file

@ -35,29 +35,31 @@ class AlbumListPage extends StatelessWidget {
builder: (context, s, child) { builder: (context, s, child) {
return ValueListenableBuilder<bool>( return ValueListenableBuilder<bool>(
valueListenable: androidFileUtils.areAppNamesReadyNotifier, valueListenable: androidFileUtils.areAppNamesReadyNotifier,
builder: (context, areAppNamesReady, child) => StreamBuilder( builder: (context, areAppNamesReady, child) {
stream: source.eventBus.on<AlbumsChangedEvent>(), return StreamBuilder(
builder: (context, snapshot) { stream: source.eventBus.on<AlbumsChangedEvent>(),
final gridItems = getAlbumGridItems(context, source); builder: (context, snapshot) {
return StreamBuilder<Set<CollectionFilter>?>( final gridItems = getAlbumGridItems(context, source);
// to update sections by tier return StreamBuilder<Set<CollectionFilter>?>(
stream: covers.packageChangeStream, // to update sections by tier
builder: (context, snapshot) => FilterNavigationPage<AlbumFilter>( stream: covers.packageChangeStream,
source: source, builder: (context, snapshot) => FilterNavigationPage<AlbumFilter>(
title: context.l10n.albumPageTitle, source: source,
sortFactor: settings.albumSortFactor, title: context.l10n.albumPageTitle,
showHeaders: settings.albumGroupFactor != AlbumChipGroupFactor.none, sortFactor: settings.albumSortFactor,
actionDelegate: AlbumChipSetActionDelegate(gridItems), showHeaders: settings.albumGroupFactor != AlbumChipGroupFactor.none,
filterSections: groupToSections(context, source, gridItems), actionDelegate: AlbumChipSetActionDelegate(gridItems),
newFilters: source.getNewAlbumFilters(context), filterSections: groupToSections(context, source, gridItems),
emptyBuilder: () => EmptyContent( newFilters: source.getNewAlbumFilters(context),
icon: AIcons.album, emptyBuilder: () => EmptyContent(
text: context.l10n.albumEmpty, icon: AIcons.album,
text: context.l10n.albumEmpty,
),
), ),
), );
); },
}, );
), },
); );
}, },
); );