adding websocket connection to room state

This commit is contained in:
efim 2023-04-23 16:04:18 +04:00
parent df35f09b71
commit 2c66a9a8c2
3 changed files with 5 additions and 4 deletions

View File

@ -31,7 +31,8 @@ lazy val frontend = project
* It provides static types for the browser DOM APIs.
*/
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.4.0",
libraryDependencies += "com.raquo" %%% "laminar" % "15.0.1"
libraryDependencies += "com.raquo" %%% "laminar" % "15.0.1",
libraryDependencies += "io.laminext" %%% "websocket" % "0.15.0"
)
.dependsOn(common)

View File

@ -24,6 +24,7 @@ object Main {
)
// TODO is this ok for state creation? link with auth component and use in another?
val appStateSignal = Var(AppState(Some(TestModels.me.id))).signal
val staticStateSignal = Var(TestModels.testRoom).signal
def appElement(): Element = {
div(
@ -32,7 +33,7 @@ object Main {
className := "h-24 w-full flex flex-for justify-center items-center bg-green-200",
p(className := "text-2xl", "Here be header"),
),
RoomView.renderRoom(TestModels.testRoom)
RoomView.renderRoom(staticStateSignal)
)
}
}

View File

@ -9,8 +9,7 @@ import industries.sunshine.planningpoker.common.Models.*
object RoomView {
// TODO this will take in signal of the room observable
// NOTE i guess "other players" would have to be in circle with 'me' as empty space in the bottom
def renderRoom(state: RoomStateView): Element = {
val roomStateSignal = Var(state).signal
def renderRoom(roomStateSignal: Signal[RoomStateView]): Element = {
// i want to number other players, for the star arrangement
val otherPlayers = roomStateSignal.map { state =>
state.players.filterNot(_.id == state.me).zipWithIndex