getCachedConfig method

Future<ProjectConfig?> getCachedConfig()

Implementation

Future<ProjectConfig?> getCachedConfig() async {
  final savedProjectConfig = await _cacheService.getProjectConfig();
  final savedLastUpdated = await _cacheService.getLastUpdated();

  if (savedProjectConfig != null && savedLastUpdated != null) {
    final currentTime = DateTime.now();
    final difference = currentTime.difference(savedLastUpdated);
    // If the cached data is less than or equal to 3 days old, return the cached configuration
    if (difference.inDays <= 3) {
      _logger.logMessage(
        'Using cached skin configuration. Last updated: $savedLastUpdated',
      );
      return savedProjectConfig;
    }
  }
  return null;
}