TF-2271 Add dnsLookupToGetJmapUrl method in login repository/datasource
Signed-off-by: dab246 <tdvu@linagora.com> (cherry picked from commit eb311420d9f7869af07605064a4e8d442486896a)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_username.dart';
|
||||
|
||||
abstract class LoginDataSource {
|
||||
Future<void> saveLoginUrl(RecentLoginUrl baseUrl);
|
||||
|
||||
Future<void> saveLoginUsername(RecentLoginUsername username);
|
||||
|
||||
Future<List<RecentLoginUrl>> getAllRecentLoginUrlLatest({int? limit, String? pattern});
|
||||
|
||||
Future<List<RecentLoginUsername>> getAllRecentLoginUsernamesLatest({int? limit, String? pattern});
|
||||
|
||||
Future<String> dnsLookupToGetJmapUrl(String emailAddress);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart';
|
||||
|
||||
abstract class LoginUrlDataSource {
|
||||
Future<void> saveLoginUrl(RecentLoginUrl baseUrl);
|
||||
|
||||
Future<List<RecentLoginUrl>> getAllRecentLoginUrlLatest({int? limit, String? pattern});
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_username.dart';
|
||||
|
||||
abstract class LoginUsernameDataSource {
|
||||
Future<void> saveLoginUsername(RecentLoginUsername username);
|
||||
|
||||
Future<List<RecentLoginUsername>> getAllRecentLoginUsernamesLatest({int? limit, String? pattern});
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import 'package:tmail_ui_user/features/caching/clients/recent_login_url_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/clients/recent_login_username_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/datasource/login_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/recent_login_url_cache.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/recent_login_username_cache.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/extensions/list_recent_login_url_extension.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/extensions/list_recent_login_username_extension.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_username.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class HiveLoginDataSourceImpl implements LoginDataSource {
|
||||
|
||||
final RecentLoginUrlCacheClient _recentLoginUrlCacheClient;
|
||||
final RecentLoginUsernameCacheClient _recentLoginUsernameCacheClient;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
HiveLoginDataSourceImpl(
|
||||
this._recentLoginUrlCacheClient,
|
||||
this._recentLoginUsernameCacheClient,
|
||||
this._exceptionThrower
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> saveLoginUrl(RecentLoginUrl recentLoginUrl) {
|
||||
return Future.sync(() async {
|
||||
if (await _recentLoginUrlCacheClient.isExistItem(recentLoginUrl.url)) {
|
||||
return await _recentLoginUrlCacheClient.updateItem(
|
||||
recentLoginUrl.url,
|
||||
recentLoginUrl.toRecentLoginUrlCache()
|
||||
);
|
||||
} else {
|
||||
return await _recentLoginUrlCacheClient.insertItem(
|
||||
recentLoginUrl.url,
|
||||
recentLoginUrl.toRecentLoginUrlCache()
|
||||
);
|
||||
}
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<RecentLoginUrl>> getAllRecentLoginUrlLatest({int? limit, String? pattern}) {
|
||||
return Future.sync(() async {
|
||||
final listRecentUrlCache = await _recentLoginUrlCacheClient.getAll();
|
||||
final listRecentUrl = listRecentUrlCache
|
||||
.where((recentCache) => _filterRecentUrlCache(recentCache, pattern))
|
||||
.map((recentCache) => recentCache.toRecentLoginUrl())
|
||||
.toList();
|
||||
listRecentUrl.sortByCreationDate();
|
||||
|
||||
final newLimit = limit ?? 5;
|
||||
|
||||
final newListRecentSUrl = listRecentUrl.length > newLimit
|
||||
? listRecentUrl.sublist(0, newLimit)
|
||||
: listRecentUrl;
|
||||
|
||||
return newListRecentSUrl;
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
bool _filterRecentUrlCache(RecentLoginUrlCache recentLoginUrlCache, String? pattern) {
|
||||
if (pattern == null || pattern.trim().isEmpty) {
|
||||
return true;
|
||||
} else {
|
||||
return recentLoginUrlCache.matchUrl(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<RecentLoginUsername>> getAllRecentLoginUsernamesLatest({int? limit, String? pattern}) {
|
||||
return Future.sync(() async {
|
||||
final listRecentUsernameCache = await _recentLoginUsernameCacheClient.getAll();
|
||||
final listValidRecentUsername = listRecentUsernameCache
|
||||
.where((recentCache) => _filterRecentLoginUsernameCache(recentCache, pattern))
|
||||
.map((recentCache) => recentCache.toRecentLoginUsername())
|
||||
.toList();
|
||||
|
||||
listValidRecentUsername.sortByCreationDate();
|
||||
|
||||
final newLimit = limit ?? 5;
|
||||
|
||||
return listValidRecentUsername.length > newLimit
|
||||
? listValidRecentUsername.sublist(0, newLimit)
|
||||
: listValidRecentUsername;
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveLoginUsername(RecentLoginUsername recentLoginUsername) {
|
||||
return Future.sync(() async {
|
||||
if (await _recentLoginUsernameCacheClient.isExistItem(recentLoginUsername.username)) {
|
||||
return await _recentLoginUsernameCacheClient.updateItem(
|
||||
recentLoginUsername.username,
|
||||
recentLoginUsername.toRecentLoginUsernameCache()
|
||||
);
|
||||
} else {
|
||||
return await _recentLoginUsernameCacheClient.insertItem(
|
||||
recentLoginUsername.username,
|
||||
recentLoginUsername.toRecentLoginUsernameCache()
|
||||
);
|
||||
}
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
bool _filterRecentLoginUsernameCache(
|
||||
RecentLoginUsernameCache recentLoginUsernameCache,
|
||||
String? pattern
|
||||
) {
|
||||
if (pattern == null || pattern.trim().isEmpty) {
|
||||
return true;
|
||||
} else {
|
||||
return recentLoginUsernameCache.matchUsername(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> dnsLookupToGetJmapUrl(String emailAddress) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import 'package:tmail_ui_user/features/login/data/datasource/login_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/dns_service.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_username.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class LoginDataSourceImpl implements LoginDataSource {
|
||||
|
||||
final DNSService _dnsService;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
LoginDataSourceImpl(
|
||||
this._dnsService,
|
||||
this._exceptionThrower
|
||||
);
|
||||
|
||||
@override
|
||||
Future<String> dnsLookupToGetJmapUrl(String emailAddress) {
|
||||
return Future.sync(() async {
|
||||
return await _dnsService.getJmapUrl(emailAddress);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<RecentLoginUrl>> getAllRecentLoginUrlLatest({int? limit, String? pattern}) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<RecentLoginUsername>> getAllRecentLoginUsernamesLatest({int? limit, String? pattern}) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveLoginUrl(RecentLoginUrl baseUrl) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveLoginUsername(RecentLoginUsername username) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
import 'package:tmail_ui_user/features/caching/clients/recent_login_url_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/datasource/login_url_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/recent_login_url_cache.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/extensions/list_recent_login_url_extension.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class LoginUrlDataSourceImpl implements LoginUrlDataSource {
|
||||
|
||||
final RecentLoginUrlCacheClient _recentLoginUrlCacheClient;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
LoginUrlDataSourceImpl(this._recentLoginUrlCacheClient, this._exceptionThrower);
|
||||
|
||||
@override
|
||||
Future<void> saveLoginUrl(RecentLoginUrl recentLoginUrl) {
|
||||
return Future.sync(() async {
|
||||
if (await _recentLoginUrlCacheClient.isExistItem(recentLoginUrl.url)) {
|
||||
await _recentLoginUrlCacheClient.updateItem(
|
||||
recentLoginUrl.url,
|
||||
recentLoginUrl.toRecentLoginUrlCache());
|
||||
} else {
|
||||
await _recentLoginUrlCacheClient.insertItem(
|
||||
recentLoginUrl.url,
|
||||
recentLoginUrl.toRecentLoginUrlCache());
|
||||
}
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<RecentLoginUrl>> getAllRecentLoginUrlLatest({int? limit, String? pattern}) {
|
||||
return Future.sync(() async {
|
||||
final listRecentUrlCache = await _recentLoginUrlCacheClient.getAll();
|
||||
final listRecentUrl = listRecentUrlCache
|
||||
.where((recentCache) => _filterRecentUrlCache(recentCache, pattern))
|
||||
.map((recentCache) => recentCache.toRecentLoginUrl())
|
||||
.toList();
|
||||
listRecentUrl.sortByCreationDate();
|
||||
|
||||
final newLimit = limit ?? 5;
|
||||
|
||||
final newListRecentSUrl = listRecentUrl.length > newLimit
|
||||
? listRecentUrl.sublist(0, newLimit)
|
||||
: listRecentUrl;
|
||||
|
||||
return newListRecentSUrl;
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
bool _filterRecentUrlCache(RecentLoginUrlCache recentLoginUrlCache, String? pattern) {
|
||||
if (pattern == null || pattern.trim().isEmpty) {
|
||||
return true;
|
||||
} else {
|
||||
return recentLoginUrlCache.matchUrl(pattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
import 'package:tmail_ui_user/features/caching/clients/recent_login_username_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/datasource/login_username_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/recent_login_username_cache.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/extensions/list_recent_login_username_extension.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_username.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class LoginUsernameDataSourceImpl implements LoginUsernameDataSource {
|
||||
|
||||
final RecentLoginUsernameCacheClient _recentLoginUsernameCacheClient;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
LoginUsernameDataSourceImpl(this._recentLoginUsernameCacheClient, this._exceptionThrower);
|
||||
|
||||
@override
|
||||
Future<List<RecentLoginUsername>> getAllRecentLoginUsernamesLatest({int? limit, String? pattern}) {
|
||||
return Future.sync(() async {
|
||||
final listRecentUsernameCache = await _recentLoginUsernameCacheClient.getAll();
|
||||
final listValidRecentUsername = listRecentUsernameCache
|
||||
.where((recentCache) => _filterRecentLoginUsernameCache(recentCache, pattern))
|
||||
.map((recentCache) => recentCache.toRecentLoginUsername())
|
||||
.toList();
|
||||
|
||||
listValidRecentUsername.sortByCreationDate();
|
||||
|
||||
final newLimit = limit ?? 5;
|
||||
|
||||
return listValidRecentUsername.length > newLimit
|
||||
? listValidRecentUsername.sublist(0, newLimit)
|
||||
: listValidRecentUsername;
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveLoginUsername(RecentLoginUsername recentLoginUsername) {
|
||||
return Future.sync(() async {
|
||||
if (await _recentLoginUsernameCacheClient
|
||||
.isExistItem(recentLoginUsername.username)) {
|
||||
await _recentLoginUsernameCacheClient.updateItem(recentLoginUsername.username,
|
||||
recentLoginUsername.toRecentLoginUsernameCache());
|
||||
} else {
|
||||
await _recentLoginUsernameCacheClient.insertItem(recentLoginUsername.username,
|
||||
recentLoginUsername.toRecentLoginUsernameCache());
|
||||
}
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
bool _filterRecentLoginUsernameCache(
|
||||
RecentLoginUsernameCache recentLoginUsernameCache,
|
||||
String? pattern
|
||||
) {
|
||||
if (pattern == null || pattern.trim().isEmpty) {
|
||||
return true;
|
||||
} else {
|
||||
return recentLoginUsernameCache.matchUsername(pattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/datasource/login_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_username.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_repository.dart';
|
||||
|
||||
class LoginRepositoryImpl implements LoginRepository {
|
||||
final Map<DataSourceType, LoginDataSource> _loginDataSource;
|
||||
|
||||
LoginRepositoryImpl(this._loginDataSource);
|
||||
|
||||
@override
|
||||
Future<void> saveRecentLoginUrl(RecentLoginUrl recentLogin) {
|
||||
return _loginDataSource[DataSourceType.hiveCache]!.saveLoginUrl(recentLogin);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<RecentLoginUrl>> getAllRecentLoginUrlLatest({int? limit, String? pattern}) {
|
||||
return _loginDataSource[DataSourceType.hiveCache]!.getAllRecentLoginUrlLatest(limit: limit, pattern: pattern);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<RecentLoginUsername>> getAllRecentLoginUsernameLatest({int? limit, String? pattern}) {
|
||||
return _loginDataSource[DataSourceType.hiveCache]!.getAllRecentLoginUsernamesLatest(limit: limit, pattern: pattern);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveLoginUsername(RecentLoginUsername recentLoginUsername) {
|
||||
return _loginDataSource[DataSourceType.hiveCache]!.saveLoginUsername(recentLoginUsername);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> dnsLookupToGetJmapUrl(String emailAddress) {
|
||||
return _loginDataSource[DataSourceType.network]!.dnsLookupToGetJmapUrl(emailAddress);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import 'package:tmail_ui_user/features/login/data/datasource/login_url_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_url_repository.dart';
|
||||
|
||||
class LoginUrlRepositoryImpl implements LoginUrlRepository {
|
||||
final LoginUrlDataSource loginInfoDataSource;
|
||||
|
||||
LoginUrlRepositoryImpl(this.loginInfoDataSource);
|
||||
|
||||
@override
|
||||
Future<void> saveRecentLoginUrl(RecentLoginUrl recentLogin) {
|
||||
return loginInfoDataSource.saveLoginUrl(recentLogin);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<RecentLoginUrl>> getAllRecentLoginUrlLatest({int? limit, String? pattern}) {
|
||||
return loginInfoDataSource.getAllRecentLoginUrlLatest(limit: limit, pattern: pattern);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import 'package:tmail_ui_user/features/login/data/datasource/login_username_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_username.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_username_repository.dart';
|
||||
|
||||
class LoginUsernameRepositoryImpl implements LoginUsernameRepository {
|
||||
final LoginUsernameDataSource loginUsernameDatasource;
|
||||
|
||||
LoginUsernameRepositoryImpl(this.loginUsernameDatasource);
|
||||
|
||||
@override
|
||||
Future<List<RecentLoginUsername>> getAllRecentLoginUsernameLatest({int? limit, String? pattern}) {
|
||||
return loginUsernameDatasource.getAllRecentLoginUsernamesLatest(limit: limit, pattern: pattern);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveLoginUsername(RecentLoginUsername recentLoginUsername) {
|
||||
return loginUsernameDatasource.saveLoginUsername(recentLoginUsername);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_username.dart';
|
||||
|
||||
abstract class LoginRepository {
|
||||
Future<void> saveRecentLoginUrl(RecentLoginUrl recentLoginUrl);
|
||||
|
||||
Future<void> saveLoginUsername(RecentLoginUsername recentLoginUsername);
|
||||
|
||||
Future<List<RecentLoginUsername>> getAllRecentLoginUsernameLatest({int? limit, String? pattern});
|
||||
|
||||
Future<List<RecentLoginUrl>> getAllRecentLoginUrlLatest({int? limit, String? pattern});
|
||||
|
||||
Future<String> dnsLookupToGetJmapUrl(String emailAddress);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart';
|
||||
|
||||
abstract class LoginUrlRepository {
|
||||
Future<void> saveRecentLoginUrl(RecentLoginUrl recentLoginUrl);
|
||||
|
||||
Future<List<RecentLoginUrl>> getAllRecentLoginUrlLatest({int? limit, String? pattern});
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_username.dart';
|
||||
|
||||
abstract class LoginUsernameRepository {
|
||||
Future<void> saveLoginUsername(RecentLoginUsername recentLoginUsername);
|
||||
|
||||
Future<List<RecentLoginUsername>> getAllRecentLoginUsernameLatest({int? limit, String? pattern});
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
|
||||
class DNSLookupToGetJmapUrlLoading extends LoadingState {}
|
||||
|
||||
class DNSLookupToGetJmapUrlSuccess extends UIState {
|
||||
final String jmapUrl;
|
||||
|
||||
DNSLookupToGetJmapUrlSuccess(this.jmapUrl);
|
||||
|
||||
@override
|
||||
List<Object> get props => [jmapUrl];
|
||||
}
|
||||
|
||||
class DNSLookupToGetJmapUrlFailure extends FeatureFailure {
|
||||
|
||||
DNSLookupToGetJmapUrlFailure(dynamic exception) : super(exception: exception);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/dns_lookup_to_get_jmap_url_state.dart';
|
||||
|
||||
class DNSLookupToGetJmapUrlInteractor {
|
||||
final LoginRepository _loginRepository;
|
||||
|
||||
DNSLookupToGetJmapUrlInteractor(this._loginRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(String emailAddress) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(DNSLookupToGetJmapUrlLoading());
|
||||
final jmapUrl = await _loginRepository.dnsLookupToGetJmapUrl(emailAddress);
|
||||
yield Right<Failure, Success>(DNSLookupToGetJmapUrlSuccess(jmapUrl));
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(DNSLookupToGetJmapUrlFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -1,19 +1,20 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_url_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/get_all_recent_login_url_latest_state.dart';
|
||||
|
||||
class GetAllRecentLoginUrlOnMobileInteractor {
|
||||
final LoginUrlRepository _loginUrlRepository;
|
||||
final LoginRepository _loginRepository;
|
||||
|
||||
GetAllRecentLoginUrlOnMobileInteractor(this._loginUrlRepository);
|
||||
GetAllRecentLoginUrlOnMobileInteractor(this._loginRepository);
|
||||
|
||||
Future<Either<Failure, Success>> execute({int? limit, String? pattern}) async {
|
||||
try{
|
||||
final listRecentUrl = await _loginUrlRepository.getAllRecentLoginUrlLatest(
|
||||
limit: limit,
|
||||
pattern: pattern);
|
||||
final listRecentUrl = await _loginRepository.getAllRecentLoginUrlLatest(
|
||||
limit: limit,
|
||||
pattern: pattern
|
||||
);
|
||||
return Right(GetAllRecentLoginUrlLatestSuccess(listRecentUrl));
|
||||
} catch(e) {
|
||||
return Left(GetAllRecentLoginUrlLatestFailure(e));
|
||||
|
||||
+9
-6
@@ -1,17 +1,20 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_username_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/get_all_recent_login_username_state.dart';
|
||||
|
||||
class GetAllRecentLoginUsernameOnMobileInteractor {
|
||||
final LoginUsernameRepository loginUsernameRepository;
|
||||
final LoginRepository _loginRepository;
|
||||
|
||||
GetAllRecentLoginUsernameOnMobileInteractor(this.loginUsernameRepository);
|
||||
GetAllRecentLoginUsernameOnMobileInteractor(this._loginRepository);
|
||||
|
||||
Future<Either<Failure, Success>> execute({int? limit, String? pattern}) async {
|
||||
try {
|
||||
final listRecent = await loginUsernameRepository.getAllRecentLoginUsernameLatest(
|
||||
limit: limit, pattern: pattern);
|
||||
final listRecent = await _loginRepository.getAllRecentLoginUsernameLatest(
|
||||
limit: limit,
|
||||
pattern: pattern
|
||||
);
|
||||
return Right(GetAllRecentLoginUsernameLatestSuccess(listRecent));
|
||||
} catch (exception) {
|
||||
return Left(GetAllRecentLoginUsernameLatestFailure(exception));
|
||||
|
||||
@@ -2,17 +2,17 @@ import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_url_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/save_recent_login_url_state.dart';
|
||||
|
||||
class SaveLoginUrlOnMobileInteractor {
|
||||
final LoginUrlRepository loginUrlRepository;
|
||||
final LoginRepository _loginRepository;
|
||||
|
||||
SaveLoginUrlOnMobileInteractor(this.loginUrlRepository);
|
||||
SaveLoginUrlOnMobileInteractor(this._loginRepository);
|
||||
|
||||
Future<Either<Failure, Success>> execute(RecentLoginUrl recentLoginUrl) async {
|
||||
try{
|
||||
await loginUrlRepository.saveRecentLoginUrl(recentLoginUrl);
|
||||
await _loginRepository.saveRecentLoginUrl(recentLoginUrl);
|
||||
return Right(SaveRecentLoginUrlSuccess());
|
||||
} catch(e) {
|
||||
return Left(SaveRecentLoginUrlFailed(e));
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/model/recent_login_username.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_username_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/login_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/save_recent_login_username_state.dart';
|
||||
|
||||
class SaveLoginUsernameOnMobileInteractor {
|
||||
final LoginUsernameRepository loginUsernameRepository;
|
||||
final LoginRepository _loginRepository;
|
||||
|
||||
SaveLoginUsernameOnMobileInteractor(this.loginUsernameRepository);
|
||||
SaveLoginUsernameOnMobileInteractor(this._loginRepository);
|
||||
|
||||
Future<Either<Failure, Success>> execute(RecentLoginUsername recentLoginUsername) async {
|
||||
try {
|
||||
await loginUsernameRepository.saveLoginUsername(recentLoginUsername);
|
||||
await _loginRepository.saveLoginUsername(recentLoginUsername);
|
||||
return Right(SaveRecentLoginUsernameSuccess());
|
||||
} catch(exception) {
|
||||
return Left(SaveRecentLoginUsernameFailed(exception));
|
||||
|
||||
Reference in New Issue
Block a user