Skip to content

Commit

Permalink
fix common.Icon usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Apr 11, 2024
1 parent 15a7d91 commit 70144d2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/templating/UserHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,4 @@ trait UserHelper extends HasEnv:
private def lineIcon(user: Option[LightUser])(using Translate): Frag = lineIcon(user.exists(_.isPatron))
def lineIcon(user: LightUser)(using Translate): Frag = lineIcon(user.isPatron)
def lineIcon(user: User)(using Translate): Frag = lineIcon(user.isPatron)
def lineIconChar(user: User): Frag = if user.isPatron then patronIconChar else lineIconChar
def lineIconChar(user: User): Icon = if user.isPatron then patronIconChar else lineIconChar
2 changes: 2 additions & 0 deletions app/ui/scalatags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ object ScalatagsTemplate extends ScalatagsTemplate
// generic extensions
trait ScalatagsExtensions:

given Render[Icon] = _.value

given [A](using Render[A]): Conversion[A, scalatags.Text.Frag] = a => StringFrag(a.render)

given opaqueIntFrag[A](using r: IntRuntime[A]): Conversion[A, Frag] = a => intFrag(r(a))
Expand Down
3 changes: 3 additions & 0 deletions modules/db/src/main/Handlers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import lila.common.Iso.{ *, given }
import lila.core.email.NormalizedEmailAddress
import lila.core.net.IpAddress
import lila.core.data.Percent
import lila.common.Icon

trait Handlers:

Expand Down Expand Up @@ -164,6 +165,8 @@ trait Handlers:

given BSONHandler[chess.Mode] = BSONBooleanHandler.as[chess.Mode](chess.Mode.apply, _.rated)

given BSONHandler[Icon] = BSONStringHandler.as[Icon](Icon(_), _.value)

given [T: BSONHandler]: BSONHandler[(T, T)] = tryHandler[(T, T)](
{ case arr: BSONArray => for a <- arr.getAsTry[T](0); b <- arr.getAsTry[T](1) yield (a, b) },
{ case (a, b) => BSONArray(a, b) }
Expand Down
1 change: 0 additions & 1 deletion modules/tournament/src/main/Spotlight.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import scalalib.HeapSort.topN
import lila.common.Icon
import lila.rating.Perf
import lila.user.{ Me, User }
import lila.common.Icon
import lila.core.LightUser

case class Spotlight(
Expand Down

0 comments on commit 70144d2

Please sign in to comment.