TF-1014: [Dev] Show quota at the bottom of mailbox
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
class NotFoundQuotasException implements Exception {
|
||||
NotFoundQuotasException();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:jmap_dart_client/jmap/quotas/quota.dart';
|
||||
|
||||
class QuotasResponse with EquatableMixin {
|
||||
final AccountId accountId;
|
||||
final State state;
|
||||
final List<Quota> quotas;
|
||||
final List<Id>? notFound;
|
||||
|
||||
QuotasResponse({
|
||||
required this.accountId,
|
||||
required this.state,
|
||||
required this.quotas,
|
||||
this.notFound,
|
||||
});
|
||||
|
||||
bool hasData() {
|
||||
return quotas.isNotEmpty;
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
quotas,
|
||||
state,
|
||||
notFound,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/model/quotas_response.dart';
|
||||
|
||||
abstract class QuotasRepository {
|
||||
Future<QuotasResponse> getQuotas(AccountId accountId);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:jmap_dart_client/jmap/quotas/quota.dart';
|
||||
|
||||
class GetQuotasSuccess extends UIState {
|
||||
final List<Quota> quotas;
|
||||
final State? state;
|
||||
|
||||
GetQuotasSuccess(this.quotas, this.state);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
quotas,
|
||||
state,
|
||||
];
|
||||
}
|
||||
|
||||
class GetQuotasFailure extends FeatureFailure {
|
||||
final dynamic exception;
|
||||
|
||||
GetQuotasFailure(this.exception);
|
||||
|
||||
@override
|
||||
List<Object> get props => [exception];
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'dart:core';
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/repository/quotas_repository.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/state/get_quotas_state.dart';
|
||||
|
||||
class GetQuotasInteractor {
|
||||
final QuotasRepository quotasRepository;
|
||||
|
||||
GetQuotasInteractor(this.quotasRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(LoadingState());
|
||||
final response = await quotasRepository.getQuotas(accountId);
|
||||
yield Right(GetQuotasSuccess(response.quotas, response.state));
|
||||
} catch (exception) {
|
||||
yield Left(GetQuotasFailure(exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user