fix(authentication): initialize account stream transformer
This commit is contained in:
parent
828c1ace6f
commit
13fc4aa875
@ -44,6 +44,19 @@ class AuthenticationRepositoryImpl<T extends Object>
|
||||
}) : _authChangeListener = onAuthChange,
|
||||
_accountStreamTransformer = accountStreamTransformer {
|
||||
_formRepository = formRepository ?? FormRepositoryImpl();
|
||||
_accountStreamTransformer ??= (input) => input
|
||||
.where((event) => event is! SignUpAuthChangeEvent)
|
||||
.map<FutureOrResult<AccountWrapper<T>>>((event) async {
|
||||
if (listener == null) {
|
||||
return Ok(AccountWrapperModel<T>(event.account, null));
|
||||
}
|
||||
// Handle sign in, sign out and refresh
|
||||
final dataResult = await listener!.call(this, event);
|
||||
return dataResult.map((data) {
|
||||
authenticationCacheDataSource.storeData(data);
|
||||
return AccountWrapperModel(event.account, data);
|
||||
});
|
||||
});
|
||||
if (formRepository != null) {
|
||||
return;
|
||||
}
|
||||
@ -90,19 +103,6 @@ class AuthenticationRepositoryImpl<T extends Object>
|
||||
name: AuthFormName.passwordResetForm,
|
||||
),
|
||||
);
|
||||
_accountStreamTransformer ??= (input) => input
|
||||
.where((event) => event is! SignUpAuthChangeEvent)
|
||||
.map<FutureOrResult<AccountWrapper<T>>>((event) async {
|
||||
if (listener == null) {
|
||||
return Ok(AccountWrapperModel<T>(event.account, null));
|
||||
}
|
||||
// Handle sign in, sign out and refresh
|
||||
final dataResult = await listener!.call(this, event);
|
||||
return dataResult.map((data) {
|
||||
authenticationCacheDataSource.storeData(data);
|
||||
return AccountWrapperModel(event.account, data);
|
||||
});
|
||||
});
|
||||
}
|
||||
final AuthenticationCacheDataSource<T> authenticationCacheDataSource;
|
||||
final AuthenticationRemoteDataSource authenticationRemoteDataSource;
|
||||
|
Loading…
x
Reference in New Issue
Block a user