Fix data in bloc state can be modified outside

This commit is contained in:
Ming Ming 2022-07-25 15:43:57 +08:00
parent 52e9618581
commit 8f8fa1db2a
3 changed files with 3 additions and 3 deletions

View file

@ -131,7 +131,7 @@ class ListImportableAlbumBloc
products.add(ev); products.add(ev);
// don't emit events too frequently // don't emit events too frequently
if (++count >= 5) { if (++count >= 5) {
emit(ListImportableAlbumBlocLoading(products)); emit(ListImportableAlbumBlocLoading(products.toList()));
} }
} }
} }

View file

@ -386,7 +386,7 @@ class ScanAccountDirBloc
files.addAll(event); files.addAll(event);
if (cache.isEmpty) { if (cache.isEmpty) {
// only emit partial results if there's no cache // only emit partial results if there's no cache
emit(ScanAccountDirBlocLoading(files)); emit(ScanAccountDirBlocLoading(files.toList()));
} }
} }
_log.info( _log.info(

View file

@ -93,7 +93,7 @@ class ScanLocalDirBloc
final products = <LocalFile>[]; final products = <LocalFile>[];
for (final p in event.relativePaths) { for (final p in event.relativePaths) {
if (shouldEmitIntermediate) { if (shouldEmitIntermediate) {
emit(ScanLocalDirBlocLoading(products)); emit(ScanLocalDirBlocLoading(products.toList()));
} }
final files = await ScanLocalDir(c)(p); final files = await ScanLocalDir(c)(p);
products.addAll(files); products.addAll(files);