fix: hide Storage section in settings menu when quota is empty

This commit is contained in:
dab246
2025-10-22 15:20:55 +07:00
committed by Dat H. Pham
parent 2f9e6d61c9
commit 7f5c48cbe3
10 changed files with 128 additions and 96 deletions
@@ -0,0 +1,47 @@
import 'package:dartz/dartz.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.dart';
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/validate_setting_capability_supported_extension.dart';
import 'package:tmail_ui_user/features/manage_account/presentation/manage_account_dashboard_controller.dart';
import 'package:tmail_ui_user/features/quotas/domain/exceptions/quotas_exception.dart';
import 'package:tmail_ui_user/features/quotas/domain/extensions/list_quotas_extensions.dart';
import 'package:tmail_ui_user/features/quotas/domain/state/get_quotas_state.dart';
import 'package:tmail_ui_user/features/quotas/domain/use_case/get_quotas_interactor.dart';
import 'package:tmail_ui_user/features/quotas/presentation/quotas_interactor_bindings.dart';
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
extension ValidateStorageMenuVisibleExtension
on ManageAccountDashBoardController {
void injectQuotaBindings() {
if (isStorageCapabilitySupported) {
QuotasInteractorBindings().dependencies();
}
}
void getQuotas(AccountId? accountId) {
if (accountId == null) {
consumeState(
Stream.value(Left(GetQuotasFailure(NotFoundAccountIdException))),
);
return;
}
getQuotasInteractor = getBinding<GetQuotasInteractor>();
if (getQuotasInteractor == null || !isStorageCapabilitySupported) {
consumeState(
Stream.value(Left(GetQuotasFailure(QuotasNotSupportedException))),
);
return;
}
consumeState(getQuotasInteractor!.execute(accountId));
}
void handleGetQuotasSuccess(GetQuotasSuccess success) {
octetsQuota.value = success.quotas.octetsQuota;
}
void handleGetQuotasFailure() {
octetsQuota.value = null;
}
}