fix lobby seek variant warning

This commit is contained in:
Thibault Duplessis 2021-06-15 16:25:37 +02:00
parent 7b1c70e355
commit 7a69ba76ed
3 changed files with 13 additions and 11 deletions

View file

@ -62,6 +62,7 @@ case class Seek(
Json.obj("key" -> pt.key)
})
.add("provisional" -> perf.exists(_.provisional))
.add("variant" -> realVariant.exotic.option(realVariant.key))
lazy val perfType = PerfPicker.perfType(Speed.Correspondence, realVariant, daysPerTurn)
}

View file

@ -24,6 +24,7 @@ export interface Seek {
key: string;
};
provisional?: boolean;
variant?: string;
action: 'joinSeek' | 'cancelSeek';
}

View file

@ -13,17 +13,17 @@ const variantConfirms = {
'This is a Crazyhouse game!\n\nEvery time a piece is captured, the capturing player gets a piece of the same type and of their color in their pocket.',
};
function storageKey(key) {
return 'lobby.variant.' + key;
}
const storageKey = key => 'lobby.variant.' + key;
export default function (variant: string) {
return Object.keys(variantConfirms).every(function (key) {
const v = variantConfirms[key];
if (variant === key && !lichess.storage.get(storageKey(key))) {
const c = confirm(v);
if (c) lichess.storage.set(storageKey(key), '1');
return c;
} else return true;
});
return (
!variant ||
Object.keys(variantConfirms).every(function (key) {
if (variant === key && !lichess.storage.get(storageKey(key))) {
const c = confirm(variantConfirms[key]);
if (c) lichess.storage.set(storageKey(key), '1');
return c;
} else return true;
})
);
}