hide anon games when rating filter is set
This commit is contained in:
parent
917601abeb
commit
392f6f2b8b
|
@ -4,6 +4,8 @@ case class RatingRange(min: Int, max: Int) {
|
|||
|
||||
def contains(rating: Int) = rating >= min && rating <= max
|
||||
|
||||
def notBroad: Option[RatingRange] = (this != RatingRange.broad) option this
|
||||
|
||||
override def toString = "%d-%d".format(min, max)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package lila.setup
|
||||
|
||||
import chess.{ Variant, Mode, Speed }
|
||||
import lila.common.RatingRange
|
||||
import lila.common.PimpedJson._
|
||||
import play.api.libs.json._
|
||||
|
||||
import lila.common.PimpedJson._
|
||||
import lila.common.RatingRange
|
||||
|
||||
case class FilterConfig(
|
||||
variant: List[Variant],
|
||||
mode: List[Mode],
|
||||
|
@ -28,7 +29,7 @@ case class FilterConfig(
|
|||
"variant" -> variant.map(_.toString),
|
||||
"mode" -> mode.map(_.toString),
|
||||
"speed" -> speed.map(_.id),
|
||||
"rating" -> List(ratingRange.min, ratingRange.max))
|
||||
"rating" -> ratingRange.notBroad.map(rr ⇒ List(rr.min, rr.max)))
|
||||
|
||||
def nonEmpty = copy(
|
||||
variant = variant.isEmpty.fold(FilterConfig.default.variant, variant),
|
||||
|
|
|
@ -2326,7 +2326,7 @@ var storage = {
|
|||
var visible = 0;
|
||||
_.each(pool, function(hook) {
|
||||
var hide = !_.contains(filter.variant, hook.variant) || !_.contains(filter.mode, hook.mode) || !_.contains(filter.speed, hook.speed) ||
|
||||
(hook.rating && (hook.rating < filter.rating[0] || hook.rating > filter.rating[1]));
|
||||
(filter.rating && (!hook.rating || (hook.rating && (hook.rating < filter.rating[0] || hook.rating > filter.rating[1]))));
|
||||
var hash = hook.mode + hook.variant + hook.time + hook.rating;
|
||||
if (hide && hook.action != 'cancel') {
|
||||
undrawHook(hook.id);
|
||||
|
|
Loading…
Reference in a new issue