improve challenge notification

This commit is contained in:
Thibault Duplessis 2013-12-25 20:09:11 +01:00
parent 8cd3cf28de
commit 79c6583bb3
7 changed files with 49 additions and 23 deletions

View file

@ -4,6 +4,8 @@ package actor
import akka.actor._
import play.api.templates.Html
import lila.game.GameRepo
import lila.user.UserRepo
import views.{ html V }
private[app] final class Renderer extends Actor {
@ -19,10 +21,15 @@ private[app] final class Renderer extends Actor {
case lila.tournament.actorApi.RemindTournament(tournament)
sender ! V.tournament.reminder(tournament)
case lila.hub.actorApi.setup.RemindChallenge(gameId, from, _)
sender ! V.setup.challengeNotification(gameId, from)
case lila.hub.actorApi.setup.RemindChallenge(gameId, from, _) {
val replyTo = sender
(GameRepo game gameId) zip (UserRepo named from) foreach {
case (Some(game), Some(user)) replyTo ! V.setup.challengeNotification(game, user)
case x logwarn(s"remind challenge $x")
}
}
case lila.hub.actorApi.RemindDeployPre sender ! V.notification.deploy("pre")
case lila.hub.actorApi.RemindDeployPre sender ! V.notification.deploy("pre")
case lila.hub.actorApi.RemindDeployPost sender ! V.notification.deploy("post")
case lila.tournament.actorApi.TournamentTable(tours)

View file

@ -13,7 +13,7 @@ import lila.lobby.actorApi.GetOpen
import lila.lobby.{ Hook, HookRepo }
import lila.setup.FilterConfig
import lila.socket.History
import lila.timeline.{ Entry, GameEntry }
import lila.timeline.Entry
import lila.tournament.Created
import lila.user.{ User, Context }
import lila.relation.RelationApi

View file

@ -2,19 +2,17 @@ package lila.app
package templating
import chess.format.Forsyth
import chess.{ Status => S, Variant, Color, Clock, Mode }
import lila.user.{ User, Context }
import lila.game.{ Game, Player, Namer }
import lila.user.Env.{ current userEnv }
import chess.{ Status S, Variant, Color, Clock, Mode }
import controllers.routes
import play.api.templates.Html
import play.api.mvc.Call
import play.api.templates.Html
import lila.game.{ Game, Player, Namer }
import lila.user.Env.{ current userEnv }
import lila.user.{ User, Context }
trait GameHelper { self: I18nHelper with UserHelper with AiHelper with StringHelper
def variantName(variant: Variant)(implicit ctx: Context) = variant match {
case Variant.Standard trans.standard.str()
case Variant.Chess960 "chess960"
@ -24,9 +22,15 @@ trait GameHelper { self: I18nHelper with UserHelper with AiHelper with StringHel
def clockName(clock: Option[Clock])(implicit ctx: Context): String =
clock.fold(trans.unlimited.str())(clockName)
def clockName(clock: Clock)(implicit ctx: Context): String =
def clockName(clock: Clock)(implicit ctx: Context): String =
trans.nbMinutesPerSidePlusNbSecondsPerMove.str(clock.limitInMinutes, clock.increment)
def clockNameNoCtx(clock: Option[Clock]): String =
clock.fold(trans.unlimited.en())(clockNameNoCtx)
def clockNameNoCtx(clock: Clock): String =
trans.nbMinutesPerSidePlusNbSecondsPerMove.en(clock.limitInMinutes, clock.increment)
def shortClockName(clock: Option[Clock])(implicit ctx: Context): String =
clock.fold(trans.unlimited.str())(Namer.shortClock)
@ -37,6 +41,11 @@ trait GameHelper { self: I18nHelper with UserHelper with AiHelper with StringHel
case Mode.Rated trans.rated.str()
}
def modeNameNoCtx(mode: Mode): String = mode match {
case Mode.Casual trans.casual.en()
case Mode.Rated trans.rated.en()
}
def playerUsername(player: Player, withRating: Boolean = true) =
Namer.player(player, withRating)(userEnv.usernameOrAnonymous).await
@ -81,7 +90,7 @@ trait GameHelper { self: I18nHelper with UserHelper with AiHelper with StringHel
case S.Draw trans.draw()
case S.Outoftime trans.timeOut()
case S.Cheat Html("Cheat detected")
case _ Html("")
case _ Html("")
}
def gameFen(game: Game, color: Color, ownerLink: Boolean = false, tv: Boolean = false)(implicit ctx: Context) = Html {

View file

@ -1,7 +1,13 @@
@(gameId: String, userId: String)
@(game: Game, user: User)
@notification.view("challenge_reminder", closable = false) {
@userIdLink(userId.some) @trans.challengeToPlay.en()
<a class="action decline" href="@routes.Setup.decline(gameId)">@trans.decline.en()</a>
<a class="action" href="@routes.Round.watcher(gameId, "white")">View challenge</a>
<div>
@userLink(user) @trans.challengeToPlay.en()
@clockNameNoCtx(game.clock)
@modeNameNoCtx(game.mode)
</div>
<div class="actions">
<a class="action decline" href="@routes.Setup.decline(game.id)">@trans.decline.en()</a>
<a class="action" href="@routes.Round.watcher(game.id, "white")">View challenge</a>
</div>
}

View file

@ -1959,10 +1959,13 @@ body.homepage #notifications {
#notifications .user_link {
display: inline-block;
}
#notifications .actions {
text-align: right;
width: 100%;
margin: 3px 0 3px 0;
}
#notifications .action {
float: right;
display: block;
margin-left: 8px;
margin-left: 10px;
}
a.hover_text > .base, a.hover_text:hover > .hover {
display: inline-block;

View file

@ -22,7 +22,7 @@ body.dark #hooks_wrap > div.tabs > a, body.dark #top div.auth .links a:hover, bo
background-color: #3e3e3e;
color: #b0b0b0;
}
body.dark #top a.signin, body.dark #top a.toggle:hover, body.dark #top .dropdown, body.dark #top a.goto_nav.current, body.dark #top a.goto_nav:hover, body.dark #top ul.language_links a.accepted {
body.dark #notifications > div, body.dark #top a.signin, body.dark #top a.toggle:hover, body.dark #top .dropdown, body.dark #top a.goto_nav.current, body.dark #top a.goto_nav:hover, body.dark #top ul.language_links a.accepted {
color: #b0b0b0;
}
body.dark #top .dropdown, body.dark #top .shown a.toggle {

1
todo
View file

@ -99,3 +99,4 @@ follow a user #chess claymore http://www.freechess.org/Help/HelpFiles/follow.htm
challenge warn rated/no clock
team menu should lead to "My teams"
atwar style chat system http://imgur.com/a/buwy3
replay games using move time