TF-1068 implement clean up save recent & get all login username
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/model/cleanup_rule.dart';
|
||||
|
||||
class RecentLoginUsernameCleanupRule extends CleanupRule {
|
||||
final int storageLimit;
|
||||
|
||||
RecentLoginUsernameCleanupRule({this.storageLimit = 10}) : super();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [storageLimit];
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/model/email_cleanup_rule.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/model/recent_login_url_cleanup_rule.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/model/recent_login_username_cleanup_rule.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/model/recent_search_cleanup_rule.dart';
|
||||
|
||||
abstract class CleanupRepository {
|
||||
@@ -8,4 +9,6 @@ abstract class CleanupRepository {
|
||||
Future<void> cleanRecentSearchCache(RecentSearchCleanupRule cleanupRule);
|
||||
|
||||
Future<void> cleanRecentLoginUrlCache(RecentLoginUrlCleanupRule cleanupRule);
|
||||
|
||||
Future<void> cleanRecentLoginUsernameCache(RecentLoginUsernameCleanupRule cleanupRule);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:core/core.dart';
|
||||
|
||||
class CleanupRecentLoginUsernameCacheSuccess extends UIState {
|
||||
|
||||
CleanupRecentLoginUsernameCacheSuccess();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class CleanupRecentLoginUsernameCacheFailure extends FeatureFailure {
|
||||
final dynamic exception;
|
||||
|
||||
CleanupRecentLoginUsernameCacheFailure(this.exception);
|
||||
|
||||
@override
|
||||
List<Object> get props => [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/cleanup/domain/model/recent_login_username_cleanup_rule.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/repository/cleanup_repository.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/state/cleanup_recent_login_username_cache_state.dart';
|
||||
|
||||
class CleanupRecentLoginUsernameCacheInteractor {
|
||||
final CleanupRepository cleanupRepository;
|
||||
|
||||
CleanupRecentLoginUsernameCacheInteractor(this.cleanupRepository);
|
||||
|
||||
Future<Either<Failure, Success>> execute(RecentLoginUsernameCleanupRule cleanupRule) async {
|
||||
try {
|
||||
await cleanupRepository.cleanRecentLoginUsernameCache(cleanupRule);
|
||||
return Right<Failure, Success>(CleanupRecentLoginUsernameCacheSuccess());
|
||||
} catch (e) {
|
||||
return Left(CleanupRecentLoginUsernameCacheFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user