#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,7 +35,8 @@ class AlbumListPage extends StatelessWidget {
builder: (context, s, child) {
return ValueListenableBuilder<bool>(
valueListenable: androidFileUtils.areAppNamesReadyNotifier,
builder: (context, areAppNamesReady, child) => StreamBuilder(
builder: (context, areAppNamesReady, child) {
return StreamBuilder(
stream: source.eventBus.on<AlbumsChangedEvent>(),
builder: (context, snapshot) {
final gridItems = getAlbumGridItems(context, source);
@ -57,7 +58,8 @@ class AlbumListPage extends StatelessWidget {
),
);
},
),
);
},
);
},
);