Skip to content

Commit

Permalink
random improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 25, 2012
1 parent 439f74e commit 966f00c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
14 changes: 3 additions & 11 deletions app/controllers/Lobby.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion app/forum/ForumEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions app/forum/Recent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
}
Expand Down
5 changes: 2 additions & 3 deletions app/http/Context.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 966f00c

Please sign in to comment.