#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
- 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

View file

@ -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)
}
}

View file

@ -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();
}
}

View file

@ -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'),

View file

@ -35,29 +35,31 @@ class AlbumListPage extends StatelessWidget {
builder: (context, s, child) {
return ValueListenableBuilder<bool>(
valueListenable: androidFileUtils.areAppNamesReadyNotifier,
builder: (context, areAppNamesReady, child) => StreamBuilder(
stream: source.eventBus.on<AlbumsChangedEvent>(),
builder: (context, snapshot) {
final gridItems = getAlbumGridItems(context, source);
return StreamBuilder<Set<CollectionFilter>?>(
// to update sections by tier
stream: covers.packageChangeStream,
builder: (context, snapshot) => FilterNavigationPage<AlbumFilter>(
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<AlbumsChangedEvent>(),
builder: (context, snapshot) {
final gridItems = getAlbumGridItems(context, source);
return StreamBuilder<Set<CollectionFilter>?>(
// to update sections by tier
stream: covers.packageChangeStream,
builder: (context, snapshot) => FilterNavigationPage<AlbumFilter>(
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,
),
),
),
);
},
),
);
},
);
},
);
},
);