fix(authentication): initialize account stream transformer
This commit is contained in:
		
							parent
							
								
									c005c3dc43
								
							
						
					
					
						commit
						7f0544d19c
					
				| @ -44,6 +44,19 @@ class AuthenticationRepositoryImpl<T extends Object> | |||||||
|   })  : _authChangeListener = onAuthChange, |   })  : _authChangeListener = onAuthChange, | ||||||
|         _accountStreamTransformer = accountStreamTransformer { |         _accountStreamTransformer = accountStreamTransformer { | ||||||
|     _formRepository = formRepository ?? FormRepositoryImpl(); |     _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) { |     if (formRepository != null) { | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
| @ -90,19 +103,6 @@ class AuthenticationRepositoryImpl<T extends Object> | |||||||
|           name: AuthFormName.passwordResetForm, |           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 AuthenticationCacheDataSource<T> authenticationCacheDataSource; | ||||||
|   final AuthenticationRemoteDataSource authenticationRemoteDataSource; |   final AuthenticationRemoteDataSource authenticationRemoteDataSource; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user