hide all ratings WIP

noratings
Thibault Duplessis 2021-10-21 10:48:40 +02:00
parent f974aa5b8c
commit 1917816fb8
8 changed files with 35 additions and 26 deletions

View File

@ -131,7 +131,7 @@ object UserInfo {
playbanApi: lila.playban.PlaybanApi
)(implicit ec: scala.concurrent.ExecutionContext) {
def apply(user: User, nbs: NbGames, ctx: Context): Fu[UserInfo] =
(ctx.noBlind ?? ratingChartApi(user)).mon(_.user segment "ratingChart") zip
((ctx.noBlind && ctx.pref.showRatings) ?? ratingChartApi(user)).mon(_.user segment "ratingChart") zip
relationApi.countFollowers(user.id).mon(_.user segment "nbFollowers") zip
!(user.is(User.lichessId) || user.isBot) ??
postApi.nbByUser(user.id).mon(_.user segment "nbForumPosts") zip

View File

@ -362,8 +362,8 @@ object activity {
)}</score>"""
}
private def ratingProgFrag(r: RatingProg) =
ratingTag(r.after.value, ratingProgress(r.diff))
private def ratingProgFrag(r: RatingProg)(implicit ctx: Context) =
ctx.pref.showRatings option ratingTag(r.after.value, ratingProgress(r.diff))
private def scoreStr(tag: String, p: Int, name: lila.i18n.I18nKey)(implicit ctx: Context) =
if (p == 0) ""

View File

@ -132,18 +132,22 @@ object widgets {
userIdLink(playerUser.id.some, withOnline = false),
br,
player.berserk option berserkIconSpan,
playerUser.rating,
player.provisional option "?",
playerUser.ratingDiff map { d =>
frag(" ", showRatingDiff(d))
}
ctx.pref.showRatings option frag(
playerUser.rating,
player.provisional option "?",
playerUser.ratingDiff map { d =>
frag(" ", showRatingDiff(d))
}
)
)
} getOrElse {
player.aiLevel map { level =>
frag(
span(aiName(level, withRating = false)),
br,
aiRating(level)
ctx.pref.showRatings option frag(
br,
aiRating(level)
)
)
} getOrElse {
(player.nameSplit.fold[Frag](anonSpan) { case (name, rating) =>

View File

@ -39,7 +39,9 @@ object mini {
if (u.lame && !ctx.me.has(u) && !isGranted(_.UserModView))
div(cls := "upt__info__warning")(trans.thisAccountViolatedTos())
else
div(cls := "upt__info__ratings")(u.best8Perfs map { showPerfRating(u, _) })
ctx.pref.showRatings option div(cls := "upt__info__ratings")(u.best8Perfs map {
showPerfRating(u, _)
})
),
ctx.userId map { myId =>
frag(

View File

@ -186,7 +186,7 @@ object header {
if (info.ratingChart.isDefined && (!u.lame || ctx.is(u) || isGranted(_.UserModView)))
div(cls := "rating-history")(spinner)
else
ctx.is(u) option newPlayer(u),
(ctx.is(u) && u.count.game < 10) option newPlayer(u),
div(cls := "profile-side")(
div(cls := "user-infos")(
!ctx.is(u) option frag(

View File

@ -29,36 +29,38 @@ object side {
"empty" -> perf.isEmpty,
"active" -> active.has(perfType)
),
href := {
href := ctx.pref.showRatings.?? {
if (isPuzzle) ctx.is(u) option routes.Puzzle.dashboard(30, "home").url
else routes.User.perfStat(u.username, perfType.key).url.some
},
span(
h3(perfType.trans),
if (isPuzzle && u.perfs.dubiousPuzzle && !ctx.is(u)) st.rating(strong("?"))
if (isPuzzle && u.perfs.dubiousPuzzle && !ctx.is(u) && ctx.pref.showRatings) st.rating(strong("?"))
else
st.rating(
if (perf.glicko.clueless) strong("?")
else
strong(
perf.glicko.intRating,
perf.provisional option "?"
),
" ",
ratingProgress(perf.progress),
" ",
ctx.pref.showRatings option frag(
if (perf.glicko.clueless) strong("?")
else
strong(
perf.glicko.intRating,
perf.provisional option "?"
),
" ",
ratingProgress(perf.progress),
" "
),
span(
if (perfType.key == "puzzle") trans.nbPuzzles.plural(perf.nb, perf.nb.localize)
else trans.nbGames.plural(perf.nb, perf.nb.localize)
)
),
rankMap get perfType map { rank =>
rankMap get perfType ifTrue ctx.pref.showRatings map { rank =>
span(cls := "rank", title := trans.rankIsUpdatedEveryNbMinutes.pluralSameTxt(15))(
trans.rankX(rank.localize)
)
}
),
iconTag("")
ctx.pref.showRatings option iconTag("")
)
}

View File

@ -91,6 +91,7 @@ private object PrefHandlers {
"insightShare" -> o.insightShare,
"keyboardMove" -> o.keyboardMove,
"zen" -> o.zen,
"ratings" -> o.ratings,
"rookCastle" -> o.rookCastle,
"moveEvent" -> o.moveEvent,
"pieceNotation" -> o.pieceNotation,

View File

@ -19,7 +19,7 @@
@include transition;
}
&:hover {
&[href]:hover {
background: mix($c-bg-box, $c-bg-page, 50%);
&::before {