Skip to content

Commit

Permalink
Merge branch 'master' into import-limit-notify
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoknjas committed Dec 20, 2024
2 parents 2da9a2d + 8c48699 commit bb7091f
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 55 deletions.
6 changes: 1 addition & 5 deletions modules/relay/src/main/RelayListing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ final class RelayListing(
display = main.round,
link = RelayListing.defaultRoundToLink(main.t) | main.round,
group = main.group,
alts = s.tail
.filter(_.round.hasStarted)
.take(2)
.map: s =>
s.round.withTour(s.t.tour)
alts = s.tail.filter(_.round.hasStarted).map(s => s.round.withTour(s.t.tour))
)

private def tierPriority(t: RelayTour) = -t.tier.so(_.v)
Expand Down
5 changes: 4 additions & 1 deletion modules/relay/src/main/RelayRound.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ object RelayRound:
case Url(url) => url.looksLikeLcc
case Urls(urls) => urls.exists(_.looksLikeLcc)
case _ => false

def hasUnsafeHttp: Option[URL] = this match
case Url(url) => Option.when(url.scheme == "http")(url)
case Urls(urls) => urls.find(_.scheme == "http")
case _ => none
def roundId: Option[RelayRoundId] = this match
case Url(url) =>
url.path.split("/") match
Expand Down
72 changes: 43 additions & 29 deletions modules/relay/src/main/ui/RelayFormUi.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package lila.relay
package ui
import play.api.data.Form

import play.api.data.Form
import lila.ui.*

import ScalatagsTemplate.{ given, * }
import lila.ui.ScalatagsTemplate.{ given, * }

case class FormNavigation(
group: Option[RelayGroup.WithTours],
Expand Down Expand Up @@ -154,30 +153,42 @@ final class RelayFormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi):
nav: FormNavigation
)(using ctx: Context) =
val broadcastEmailContact = a(href := "mailto:[email protected]")("[email protected]")
val lccWarning = nav.round
.flatMap(_.sync.upstream)
.exists(_.hasLcc)
.option:
flashMessage("box relay-form__lcc-deprecated")(
p(strong("Please use the ", a(href := broadcasterUrl)("Lichess Broadcaster App"))),
p(
"LiveChessCloud support is deprecated and will be removed soon.",
br,
s"If you need help, please contact us at ",
broadcastEmailContact,
"."
)
)
val contactUsForOfficial = nav.featurableRound.isDefined
.option:
flashMessage("box relay-form__contact-us")(
p(
"Is this a tournament you organize? Do you want Lichess to feature it on the ",
a(href := routes.RelayTour.index(1))("broadcast page"),
"?"
),
p(trans.contact.sendEmailAt(broadcastEmailContact))
)
val lccWarning = for
round <- nav.round
upstream <- round.sync.upstream
if upstream.hasLcc
yield flashMessage("box relay-form__warning")(
p(strong("Please use the ", a(href := broadcasterUrl)("Lichess Broadcaster App"))),
p(
"LiveChessCloud support is deprecated and will be removed soon.",
br,
s"If you need help, please contact us at ",
broadcastEmailContact,
"."
)
)
val contactUsForOfficial = nav.featurableRound.isDefined.option:
flashMessage("box relay-form__contact-us")(
p(
"Is this a tournament you organize? Do you want Lichess to feature it on the ",
a(href := routes.RelayTour.index(1))("broadcast page"),
"?"
),
p(trans.contact.sendEmailAt(broadcastEmailContact))
)
val httpWarning = for
round <- nav.round
upstream <- round.sync.upstream
http <- upstream.hasUnsafeHttp
https = http.withScheme("https").withPort(-1) // else it adds :80 for some reason
yield flashMessage("box relay-form__warning")(
p(
strong("Warning: a source uses an insecure http:// protocol:"),
br,
a(href := http.toString)(http.toString)
),
p("Did you mean ", a(href := https.toString)(https.toString), "?")
)
postForm(cls := "form3", action := url)(
(!Granter.opt(_.StudyAdmin)).option:
div(cls := "form-group")(
Expand All @@ -195,7 +206,7 @@ final class RelayFormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi):
"Where do the games come from?"
)(form3.select(_, RelayRoundForm.sourceTypes)),
div(cls := "relay-form__sync relay-form__sync-url")(
lccWarning.orElse(contactUsForOfficial),
httpWarning.orElse(lccWarning).orElse(contactUsForOfficial),
form3.group(
form("syncUrl"),
trb.sourceSingleUrl(),
Expand Down Expand Up @@ -235,7 +246,10 @@ final class RelayFormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi):
help = frag("The games will be combined in the order of the URLs.").some,
half = false
)(field =>
frag(lccWarning, form3.textarea(field)(rows := 5, spellcheck := "false", cls := "monospace"))
frag(
httpWarning.orElse(lccWarning),
form3.textarea(field)(rows := 5, spellcheck := "false", cls := "monospace")
)
)(cls := "relay-form__sync relay-form__sync-urls none"),
form3.group(
form("syncIds"),
Expand Down
26 changes: 15 additions & 11 deletions modules/relay/src/main/ui/RelayTourUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class RelayTourUi(helpers: Helpers, ui: RelayUi):
val selected = active.filter(_.tour.tierIs(selector))
selected.nonEmpty.option(st.section(cls := s"relay-cards relay-cards--tier-$tier"):
selected.map: sel =>
card.render(sel, live = _.display.hasStarted, alts = sel.alts)
card.render(sel, live = _.display.hasStarted, alt = sel.alts.headOption)
)
Page(trc.liveBroadcasts.txt())
.css("bits.relay.index")
Expand All @@ -51,7 +51,12 @@ final class RelayTourUi(helpers: Helpers, ui: RelayUi):
)

private def adminIndex(active: List[RelayCard])(using Context) =
val errored = active.flatMap(a => a.errors.some.filter(_.nonEmpty).map(a -> _))
val errored = for
main <- active
card <- main :: main.alts.map: alt =>
RelayCard(tour = alt.tour, display = alt.round, link = alt.round, group = main.group, alts = Nil)
errors <- card.errors.some.filter(_.nonEmpty)
yield (card, errors)
errored.nonEmpty.option:
div(cls := "relay-index__admin")(
h2("Ongoing broadcasts with errors"),
Expand Down Expand Up @@ -240,14 +245,20 @@ final class RelayTourUi(helpers: Helpers, ui: RelayUi):
def render[A <: RelayRound.AndTourAndGroup](
tr: A,
live: A => Boolean,
alts: List[RelayRound.WithTour] = Nil,
alt: Option[RelayRound.WithTour] = None,
errors: List[String] = Nil
)(using Context) =
link(tr.tour, tr.path, live(tr))(
image(tr.tour),
span(cls := "relay-card__body")(
span(cls := "relay-card__info")(
tr.tour.active.option(span(cls := "relay-card__round")(tr.display.name)),
tr.tour.active.option:
span(cls := "relay-card__round")(
tr.display.name,
(tr.group, alt).mapN: (group, alt) =>
frag(" & ", group.shortTourName(alt.tour.name))
)
,
if live(tr)
then
span(cls := "relay-card__live")(
Expand All @@ -260,13 +271,6 @@ final class RelayTourUi(helpers: Helpers, ui: RelayUi):
else tr.display.startedAt.orElse(tr.display.startsAtTime).map(momentFromNow)
),
h3(cls := "relay-card__title")(tr.group.fold(tr.tour.name.value)(_.value)),
tr.group
.ifTrue(alts.nonEmpty)
.map: group =>
ul(cls := "relay-card__alts"):
alts.map: alt =>
li(group.shortTourName(alt.tour.name))
,
if errors.nonEmpty
then ul(cls := "relay-card__errors")(errors.map(li(_)))
else truncatedPlayers(tr.tour)
Expand Down
2 changes: 1 addition & 1 deletion modules/user/src/main/NoteApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class NoteApi(coll: Coll)(using Executor) extends lila.core.user.NoteApi:
import reactivemongo.api.bson.*
private given bsonHandler: BSONDocumentHandler[Note] = Macros.handler[Note]

def getForMyPermissions(user: User, max: Max = Max(20))(using me: Me): Fu[List[Note]] =
def getForMyPermissions(user: User, max: Max = Max(30))(using me: Me): Fu[List[Note]] =
coll
.find(
$doc("to" -> user.id) ++ {
Expand Down
2 changes: 1 addition & 1 deletion ui/bits/css/relay/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}
}

.relay-form__lcc-deprecated {
.relay-form__warning {
border: 5px solid $m-brag_bg--mix-70;

&::before {
Expand Down
6 changes: 3 additions & 3 deletions ui/mod/css/_user.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@
}

&--kaladin {
order: 8;
order: 9;
}

&--irwin {
order: 9;
order: 10;
}

&--timeline {
order: 10;
order: 8;
}

&--assessments {
Expand Down
1 change: 1 addition & 0 deletions ui/round/css/_constants.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ $col1-mat-height: $col1-player-clock-height * 2 / 5;
$col1-moves-height: 4em;
$move-tag: 'kwdb';
$rmoves-tag: 'rm6';
$rbuttons-tag: 'rb1';
$moves-tag: 'l4x';
$index-tag: 'i5z';
$active-class: 'a1t';
2 changes: 1 addition & 1 deletion ui/round/css/_moves-col1.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
}
}

.buttons {
#{$rbuttons-tag} {
display: none;
}

Expand Down
2 changes: 1 addition & 1 deletion ui/round/css/_moves.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $buttons-height: 2.5rem;
@extend %flex-column, %double-tap;
position: relative;

.buttons {
#{$rbuttons-tag} {
@extend %box-shadow;

flex: 0 0 $buttons-height;
Expand Down
5 changes: 3 additions & 2 deletions ui/round/src/view/replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const scrollMax = 99999,
indexTag = 'i5z',
indexTagUC = indexTag.toUpperCase(),
movesTag = 'l4x',
rmovesTag = 'rm6';
rmovesTag = 'rm6',
rbuttonsTag = 'rb1';

const autoScroll = throttle(100, (movesEl: HTMLElement, ctrl: RoundController) =>
window.requestAnimationFrame(() => {
Expand Down Expand Up @@ -146,7 +147,7 @@ const goThroughMoves = (ctrl: RoundController, e: Event) => {
function renderButtons(ctrl: RoundController) {
const firstPly = util.firstPly(ctrl.data),
lastPly = util.lastPly(ctrl.data);
return h('div.buttons', [
return h(rbuttonsTag, [
analysisButton(ctrl) || h('div.noop'),
...[
[licon.JumpFirst, firstPly],
Expand Down

0 comments on commit bb7091f

Please sign in to comment.