random improvements
This commit is contained in:
parent
439f74ec29
commit
966f00cce0
|
@ -23,19 +23,11 @@ object Lobby extends LilaController with Results {
|
|||
private def featured = env.game.featured
|
||||
private def openTours = env.tournament.repo.created
|
||||
|
||||
val home = Open { implicit ctx ⇒
|
||||
Async {
|
||||
renderHome(none, Ok)
|
||||
}
|
||||
}
|
||||
val home = Open { implicit ctx ⇒ Async { renderHome(none, Ok) } }
|
||||
|
||||
def handleNotFound(req: RequestHeader): Result =
|
||||
handleNotFound(reqToCtx(req))
|
||||
def handleNotFound(req: RequestHeader): Result = handleNotFound(reqToCtx(req))
|
||||
|
||||
def handleNotFound(implicit ctx: Context): Result =
|
||||
Async {
|
||||
renderHome(none, NotFound)
|
||||
}
|
||||
def handleNotFound(implicit ctx: Context): Result = Async { renderHome(none, NotFound) }
|
||||
|
||||
private def renderHome[A](myHook: Option[Hook], status: Status)(implicit ctx: Context): Promise[Result] =
|
||||
preloader(
|
||||
|
|
|
@ -30,7 +30,8 @@ final class ForumEnv(
|
|||
lazy val postApi = new PostApi(this, modLog, ForumPostMaxPerPage)
|
||||
|
||||
lazy val recent = new Recent(
|
||||
env = this,
|
||||
postRepo = postRepo,
|
||||
postApi = postApi,
|
||||
timeout = ForumRecentTimeout)
|
||||
|
||||
lazy val forms = new DataForm(captcha)
|
||||
|
|
|
@ -7,7 +7,7 @@ import security.{ Permission, Granter }
|
|||
|
||||
import scalaz.effects._
|
||||
|
||||
final class Recent(env: ForumEnv, timeout: Int) {
|
||||
final class Recent(postRepo: PostRepo, postApi: PostApi, timeout: Int) {
|
||||
|
||||
val nb = 30
|
||||
|
||||
|
@ -22,8 +22,8 @@ final class Recent(env: ForumEnv, timeout: Int) {
|
|||
val invalidate: IO[Unit] = io(cache.invalidateAll)
|
||||
|
||||
private def fetch(staff: Boolean): IO[List[PostView]] = for {
|
||||
posts ← env.postRepo.recent(nb)
|
||||
views ← (posts map env.postApi.view).sequence
|
||||
posts ← postRepo.recent(nb)
|
||||
views ← (posts map postApi.view).sequence
|
||||
} yield views collect {
|
||||
case Some(v) if (staff || v.categ.slug != "staff") ⇒ v
|
||||
}
|
||||
|
|
|
@ -12,10 +12,9 @@ sealed abstract class Context(val req: RequestHeader, val me: Option[User]) {
|
|||
|
||||
def isAnon = !isAuth
|
||||
|
||||
def canSeeChat = me.fold(m ⇒ !m.isChatBan, false)
|
||||
def canSeeChat = me.fold(!_.isChatBan, false)
|
||||
|
||||
def isGranted(permission: Permission): Boolean =
|
||||
me.fold(Granter(permission), false)
|
||||
def isGranted(permission: Permission): Boolean = me.fold(Granter(permission), false)
|
||||
|
||||
def is(user: User): Boolean = me == Some(user)
|
||||
|
||||
|
|
Loading…
Reference in a new issue