refactored lesson details, centralized logout logic, and added resume re-fetch

This commit is contained in:
2026-05-06 16:27:45 +02:00
parent 71506aab2d
commit 50d2941e52
11 changed files with 309 additions and 68 deletions
@@ -60,10 +60,27 @@ abstract class LoadableHydratedBloc<
error: event.error
)));
on<Reset<TState>>((event, emit) => emit(const LoadableState(
isLoading: false,
data: null,
lastFetch: null,
reFetch: null,
error: null,
)));
_repository = repository();
fetch();
}
/// Wipes this bloc's persisted state and resets the in-memory state to an
/// empty, non-loading shell. Intended for logout: callers must trigger a
/// fresh [fetch] (e.g. via [retry] or page-specific refresh) once the user
/// is authenticated again, otherwise the UI would stay blank.
Future<void> reset() async {
await clear();
add(Reset<TState>());
}
TState? get innerState => state.data;
TRepository get repo => _repository;
@@ -14,3 +14,4 @@ class Error<TState> extends LoadableHydratedBlocEvent<TState> {
Error(this.error);
}
class RefetchStarted<TState> extends LoadableHydratedBlocEvent<TState> {}
class Reset<TState> extends LoadableHydratedBlocEvent<TState> {}