Skip to content

Commit

Permalink
Add guard in case of list with one element in CardStylePicker
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannakok committed Nov 18, 2022
1 parent 67a4c99 commit 6fc0b4f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions common/app/model/CardStylePicker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@ object CardStylePicker {
def apply(content: CapiContent): CardStyle = {
val tags = content.tags.map(_.id).toSeq
extractCampaigns(tags) match {
case Nil => CardStyle(content, TrailMetaData.empty)
case campaign :: _ =>
if (campaign.id.toString.toLowerCase() == "specialreportalt") SpecialReportAlt else SpecialReport
case _ => SpecialReport
case Nil => CardStyle(content, TrailMetaData.empty)
case campaign :: Nil if campaign.id.toString.toLowerCase() == "specialreportalt" => SpecialReportAlt
case _ => SpecialReport
}
}

def apply(content: FaciaContent): CardStyle = {
val tags = FaciaContentUtils.tags(content).map(_.id)
extractCampaigns(tags) match {
case Nil => FaciaContentUtils.cardStyle(content)
case campaign :: _ =>
if (campaign.id.toString.toLowerCase() == "specialreportalt") SpecialReportAlt else SpecialReport
case _ => SpecialReport
case Nil => FaciaContentUtils.cardStyle(content)
case campaign :: Nil if campaign.id.toString.toLowerCase() == "specialreportalt" => SpecialReportAlt
case _ => SpecialReport
}
}

Expand Down

0 comments on commit 6fc0b4f

Please sign in to comment.