fix rating range for non-pool "new opponent" games

pull/6909/head
Thibault Duplessis 2020-06-30 11:30:15 +02:00
parent 7b21384341
commit 67249c1f76
5 changed files with 8 additions and 3 deletions

View File

@ -194,7 +194,7 @@ final class Setup(
_ ?? { game =>
for {
blocking <- ctx.userId ?? env.relation.api.fetchBlocking
hookConfig = lila.setup.HookConfig.default updateFrom game
hookConfig = lila.setup.HookConfig.default withRatingRange get("rr") updateFrom game
sameOpponents = game.userIds
hookResult <-
processor

View File

@ -37,7 +37,8 @@ object RatingRange {
if min < max
} yield RatingRange(min, max)
def orDefault(from: String) = apply(from) | default
def orDefault(from: String) = apply(from) | default
def orDefault(from: Option[String]) = from.flatMap(apply) | default
def noneIfDefault(from: String) =
if (from == default.toString) none

View File

@ -102,6 +102,8 @@ case class HookConfig(
days = game.daysPerTurn | days,
mode = game.mode
)
def withRatingRange(str: Option[String]) = copy(ratingRange = RatingRange orDefault str)
}
object HookConfig extends BaseHumanConfig {

View File

@ -32,7 +32,7 @@ module.exports = function(cfg, element) {
onFirstConnect = function() {
var gameId = getParameterByName('hook_like');
if (!gameId) return;
$.post('/setup/hook/' + lichess.sri + '/like/' + gameId);
$.post(`/setup/hook/${lichess.sri}/like/${gameId}?rr=${lobby.setup.ratingRange() || ''}`);
lobby.setTab('real_time');
history.replaceState(null, null, '/');
},

View File

@ -11,6 +11,8 @@ export default class Setup {
ai: FormStore;
}
ratingRange = () => this.stores.hook.get()?.ratingRange;
constructor(makeStorage: (name: string) => LichessStorage, readonly root: LobbyController) {
this.stores = {
hook: makeStore(makeStorage('lobby.setup.hook')),