isClickThresholdCrossed method

bool isClickThresholdCrossed(
  1. Map<String, dynamic> viewJson
)

Implementation

bool isClickThresholdCrossed(Map<String, dynamic> viewJson) {
  try {
    int? clickThreshold = viewJson['clickThreshold'];
    if (clickThreshold == null) {
      return false;
    }

    String id = viewJson['id'];
    int updatedAt = viewJson['updated_at'];
    String key = id + updatedAt.toString();
    Map<String, dynamic>? decodedMap = logMap[key];
    int clickedTillNow = decodedMap != null ? decodedMap['clicks'] ?? 0 : 0;

    if (clickThreshold == 0) {
      return false;
    }
    return clickedTillNow >= clickThreshold;
  } catch(e){
    return true;
  }
}