TF-2064 Handle limit storage to show warning banner
(cherry picked from commit 3e36cebd5cbe880f9832c62463e71979e15e1741)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/model/quotas_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/quotas/quota.dart';
|
||||
|
||||
abstract class QuotasDataSource {
|
||||
Future<QuotasResponse> getQuotas(AccountId accountId);
|
||||
Future<List<Quota>> getQuotas(AccountId accountId);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/quotas/quota.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/data/datasource/quotas_data_source.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/data/network/quotas_api.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/model/quotas_response.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class QuotasDataSourceImpl extends QuotasDataSource{
|
||||
class QuotasDataSourceImpl extends QuotasDataSource {
|
||||
final QuotasAPI _quotasAPI;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
QuotasDataSourceImpl(this._quotasAPI, this._exceptionThrower);
|
||||
|
||||
@override
|
||||
Future<QuotasResponse> getQuotas(AccountId accountId) {
|
||||
Future<List<Quota>> getQuotas(AccountId accountId) {
|
||||
return Future.sync(() async {
|
||||
return await _quotasAPI.getQuotas(accountId);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
|
||||
@@ -3,36 +3,30 @@ import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/jmap_request.dart';
|
||||
import 'package:jmap_dart_client/jmap/quotas/get/get_quota_method.dart';
|
||||
import 'package:jmap_dart_client/jmap/quotas/get/get_quota_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/quotas/quota.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/exceptions/quotas_exception.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/model/quotas_response.dart';
|
||||
|
||||
class QuotasAPI {
|
||||
final HttpClient _httpClient;
|
||||
|
||||
QuotasAPI(this._httpClient);
|
||||
|
||||
Future<QuotasResponse> getQuotas(AccountId accountId) async {
|
||||
final requestBuilder =
|
||||
JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
Future<List<Quota>> getQuotas(AccountId accountId) async {
|
||||
final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
final getQuotaMethod = GetQuotaMethod(accountId);
|
||||
final getQuotaInvocation = requestBuilder.invocation(getQuotaMethod);
|
||||
final response = await (requestBuilder
|
||||
..usings(getQuotaMethod.requiredCapabilities))
|
||||
.build()
|
||||
.execute();
|
||||
..usings(getQuotaMethod.requiredCapabilities))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
final getQuotaResponse = response.parse<GetQuotaResponse>(
|
||||
getQuotaInvocation.methodCallId,
|
||||
GetQuotaResponse.deserialize,
|
||||
);
|
||||
|
||||
if(getQuotaResponse != null) {
|
||||
return QuotasResponse(
|
||||
accountId: getQuotaResponse.accountId,
|
||||
notFound: getQuotaResponse.notFound,
|
||||
quotas: getQuotaResponse.list,
|
||||
state: getQuotaResponse.state,
|
||||
);
|
||||
if (getQuotaResponse?.list.isNotEmpty == true) {
|
||||
return getQuotaResponse!.list;
|
||||
} else {
|
||||
throw NotFoundQuotasException();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/quotas/quota.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/data/datasource/quotas_data_source.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/model/quotas_response.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/repository/quotas_repository.dart';
|
||||
|
||||
class QuotasRepositoryImpl extends QuotasRepository {
|
||||
@@ -9,7 +9,7 @@ class QuotasRepositoryImpl extends QuotasRepository {
|
||||
QuotasRepositoryImpl(this._dataSource);
|
||||
|
||||
@override
|
||||
Future<QuotasResponse> getQuotas(AccountId accountId) {
|
||||
Future<List<Quota>> getQuotas(AccountId accountId) {
|
||||
return _dataSource.getQuotas(accountId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user