scalafmt all

This commit is contained in:
efim 2023-04-25 10:25:36 +04:00
parent 0a721b135f
commit 2244f38348
10 changed files with 133 additions and 129 deletions

View File

@ -1,2 +1,3 @@
runner.dialect = scala3
version = 3.7.3
maxColumn = 100

View File

@ -14,15 +14,14 @@ trait Auth[F[_]] {
/** for middleware that converts sessionId into PlayerId
*/
def authUser
: Kleisli[[A] =>> cats.data.OptionT[F, A], Request[F], (PlayerID, RoomID)]
def authUser: Kleisli[[A] =>> cats.data.OptionT[F, A], Request[F], (PlayerID, RoomID)]
/** Get sessionId for accessing a room
* @param roomPassword
* \- requirement to get access to the room
*
* check that room exists, password is valid call to add user to the players
* create session mapping and return cookie
* check that room exists, password is valid call to add user to the players create session
* mapping and return cookie
*/
def joinRoom(
roomName: String,
@ -75,9 +74,8 @@ object Auth {
???
}
override def authUser: Kleisli[[A] =>> cats.data.OptionT[F, A], Request[
F
], (PlayerID, RoomID)] = {
override def authUser
: Kleisli[[A] =>> cats.data.OptionT[F, A], Request[F], (PlayerID, RoomID)] = {
// check authcookie presence, exchange it for playerID ad roomID
???
}

View File

@ -26,7 +26,9 @@ object MyHttpService {
val send: Stream[IO, WebSocketFrame] =
Stream
.emits(TestModels.testChangesList)
.covary[IO].metered(1.second).map(state => WebSocketFrame.Text(state.asJson.noSpaces))
.covary[IO]
.metered(1.second)
.map(state => WebSocketFrame.Text(state.asJson.noSpaces))
val receive: Pipe[IO, WebSocketFrame, Unit] = _.evalMap {
case WebSocketFrame.Text(text, _) => Sync[IO].delay(println(text))

View File

@ -15,8 +15,7 @@ trait RoomService[F[_]] {
def getRoom(roomID: RoomID): F[Option[Room]]
}
class InMemoryRoomService[F[_]: Sync](stateRef: Ref[F, Map[RoomID, Room]])
extends RoomService[F] {
class InMemoryRoomService[F[_]: Sync](stateRef: Ref[F, Map[RoomID, Room]]) extends RoomService[F] {
override def createRoom(newRoom: Room): F[Either[RoomError, Room]] = {
stateRef.modify { rooms =>
rooms.get(newRoom.id) match {

View File

@ -55,7 +55,7 @@ lazy val backend = project
libraryDependencies += "co.fs2" %% "fs2-core" % "3.6.1",
libraryDependencies += "org.typelevel" %% "cats-core" % "2.9.0",
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.9",
assembly / mainClass := Some("industries.sunshine.planningpoker.BackendApp"),
assembly / mainClass := Some("industries.sunshine.planningpoker.BackendApp")
)
.dependsOn(common.jvm)
@ -76,6 +76,8 @@ lazy val commonJS = common.js.settings(
// scalaJS specific settings
scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.ESModule)
.withModuleSplitStyle(ModuleSplitStyle.SmallModulesFor(List("industries.sunshine.planningpoker")))
.withModuleSplitStyle(
ModuleSplitStyle.SmallModulesFor(List("industries.sunshine.planningpoker"))
)
}
)

View File

@ -37,8 +37,8 @@ object Models {
enum RoundState derives Codec.AsObject:
/** view state for round before votes are open player can know their vote
* and who of the other players have voted
/** view state for round before votes are open player can know their vote and who of the other
* players have voted
*/
case Voting(
myCard: Option[String],

View File

@ -4,5 +4,6 @@ import io.circe.generic.semiauto._
import io.circe._
object Requests {
final case class LogIn(roomName: String, nickname: String, password: String) derives Codec.AsObject
final case class LogIn(roomName: String, nickname: String, password: String)
derives Codec.AsObject
}

View File

@ -30,7 +30,9 @@ object Main {
import io.laminext.websocket.circe.WebSocket._
import io.laminext.websocket.circe.webSocketReceiveBuilderSyntax
val roomStateWSStream = io.laminext.websocket.WebSocket.path("/api/subscribe").json[RoomStateView, Unit]
val roomStateWSStream = io.laminext.websocket.WebSocket
.path("/api/subscribe")
.json[RoomStateView, Unit]
.build(
managed = true,
autoReconnect = false,

View File

@ -13,16 +13,15 @@ object TableView {
// so, it's more efficient to share an observable, than to create multiple copies...
def renderTable(roundSignal: Signal[RoomStateView]): Element = {
val playerIdToCardTypeSignal =
roundSignal.combineWith(Main.appStateSignal.map(_.myId)).map((state, myIdOpt) =>
state.players.map(p =>
p.id -> getPlayerCardType(p.id, state.round, p.name, myIdOpt)
)
roundSignal
.combineWith(Main.appStateSignal.map(_.myId))
.map((state, myIdOpt) =>
state.players.map(p => p.id -> getPlayerCardType(p.id, state.round, p.name, myIdOpt))
)
div(
className := "w-full h-full border-2 border-amber-700 flex flex-row justify-center items-center bg-green-100",
children <-- playerIdToCardTypeSignal.split(_._1) {
(id, initial, cardTypeSignal) =>
children <-- playerIdToCardTypeSignal.split(_._1) { (id, initial, cardTypeSignal) =>
renderPlayerCard(cardTypeSignal.map(_._2))
}
)
@ -71,7 +70,7 @@ object TableView {
case CardBack => ""
case Open(vote) => vote
}
),
)
)
}