diff --git a/lib/bloc/scan_dir.dart b/lib/bloc/scan_dir.dart index 8e43733e..5ec1c199 100644 --- a/lib/bloc/scan_dir.dart +++ b/lib/bloc/scan_dir.dart @@ -125,6 +125,7 @@ class ScanDirBloc extends Bloc { _fileRemovedEventListener.begin(); _filePropertyUpdatedEventListener.begin(); _fileTrashbinRestoredEventListener.begin(); + _fileMovedEventListener.begin(); _refreshThrottler = Throttler( onTriggered: (_) { @@ -272,6 +273,19 @@ class ScanDirBloc extends Bloc { ); } + void _onFileMovedEvent(FileMovedEvent ev) { + if (state is ScanDirBlocInit) { + // no data in this bloc, ignore + return; + } + if (file_util.isSupportedFormat(ev.file)) { + _refreshThrottler.trigger( + maxResponceTime: const Duration(seconds: 3), + maxPendingCount: 10, + ); + } + } + Stream _queryOffline( ScanDirBlocQueryBase ev, ScanDirBlocState Function() getState) => _queryWithFileDataSource(ev, getState, FileAppDbDataSource()); @@ -308,6 +322,8 @@ class ScanDirBloc extends Bloc { _filePropertyUpdatedEventListener; late final AppEventListener _fileTrashbinRestoredEventListener; + late final _fileMovedEventListener = + AppEventListener(_onFileMovedEvent); late Throttler _refreshThrottler;