refactored lesson details, centralized logout logic, and added resume re-fetch
This commit is contained in:
+17
@@ -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;
|
||||
|
||||
|
||||
+1
@@ -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> {}
|
||||
|
||||
Reference in New Issue
Block a user