Fix refresh indicator in the new home photos

This commit is contained in:
Ming Ming 2024-01-13 21:59:25 +08:00
parent 0b3aa72015
commit 5f7d898078
2 changed files with 11 additions and 4 deletions

View file

@ -104,6 +104,7 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
void _onReload(_Reload ev, Emitter<_State> emit) {
_log.info(ev);
emit(state.copyWith(syncProgress: const Progress(0)));
_syncRemote();
}
@ -289,7 +290,8 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
if (!isClosed) {
add(const _SetSyncProgress(null));
}
_log.info("[_syncRemote] Elapsed time: ${stopwatch.elapsedMilliseconds}ms");
_log.info(
"[_syncRemote] Elapsed time: ${stopwatch.elapsedMilliseconds}ms");
});
}

View file

@ -142,8 +142,7 @@ class _WrappedHomePhotosState extends State<_WrappedHomePhotos> {
],
child: _BlocSelector<bool>(
selector: (state) =>
state.files.isEmpty &&
state.syncProgress != null,
state.files.isEmpty && state.syncProgress != null,
builder: (context, isInitialSyncing) {
if (isInitialSyncing) {
return const _InitialSyncBody();
@ -276,7 +275,13 @@ class _BodyState extends State<_Body> {
child: RefreshIndicator(
onRefresh: () async {
_bloc.add(const _Reload());
await _bloc.stream.first;
var hasNotNull = false;
await _bloc.stream.firstWhere((s) {
if (s.syncProgress != null) {
hasNotNull = true;
}
return hasNotNull && s.syncProgress == null;
});
},
child: CustomScrollView(
controller: _scrollController,