Cache LinagoraEcosystem to avoid multiple network calls

This commit is contained in:
Théo Poizat
2026-02-26 10:43:18 +01:00
committed by Dat H. Pham
parent 71901b2640
commit 6d8d10cf26
4 changed files with 164 additions and 22 deletions
@@ -0,0 +1,27 @@
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/linagora_ecosystem.dart';
class LinagoraEcosystemCache {
static final LinagoraEcosystemCache _instance = LinagoraEcosystemCache._internal();
factory LinagoraEcosystemCache() => _instance;
LinagoraEcosystemCache._internal();
final Map<String, LinagoraEcosystem> _cache = {};
void cacheEcosystem(LinagoraEcosystem ecosystem, String baseUrl) {
_cache[baseUrl] = ecosystem;
}
LinagoraEcosystem? getCachedEcosystem(String baseUrl) {
return _cache[baseUrl];
}
void clearCache() {
_cache.clear();
}
bool hasCachedEcosystem(String baseUrl) {
return _cache.containsKey(baseUrl);
}
}