From fe7cd3820048edbf1b77648358be8ae622c9a31b Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 9 Sep 2022 00:39:17 +0800 Subject: [PATCH] Fix metadata task in some cases does not start unless refreshing twice --- app/lib/widget/home_photos.dart | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/lib/widget/home_photos.dart b/app/lib/widget/home_photos.dart index 56550ace..9532a7c5 100644 --- a/app/lib/widget/home_photos.dart +++ b/app/lib/widget/home_photos.dart @@ -381,12 +381,7 @@ class _HomePhotosState extends State itemStreamListItems = []; } else if (state is ScanAccountDirBlocSuccess || state is ScanAccountDirBlocLoading) { - _transformItems(state.files); - if (state is ScanAccountDirBlocSuccess) { - _isScrollbarVisible = true; - _startupSync(); - _tryStartMetadataTask(); - } + _transformItems(state.files, isPostSuccess: true); } else if (state is ScanAccountDirBlocFailure) { _isScrollbarVisible = true; _transformItems(state.files); @@ -551,7 +546,11 @@ class _HomePhotosState extends State } /// Transform a File list to grid items - void _transformItems(List files, {bool isSorted = false}) { + void _transformItems( + List files, { + bool isSorted = false, + bool isPostSuccess = false, + }) { _log.info("[_transformItems] Queue ${files.length} items"); final c = KiwiContainer().resolve(); final PhotoListItemSorter? sorter; @@ -583,6 +582,12 @@ class _HomePhotosState extends State _backingFiles = result.backingFiles; itemStreamListItems = result.listItems; _smartAlbums = result.smartAlbums; + + if (isPostSuccess) { + _isScrollbarVisible = true; + _startupSync(); + _tryStartMetadataTask(); + } }); } },