models: separate backend room model

not viewable on front end, since doesn't have json codecs, yay!
This commit is contained in:
efim
2023-04-27 22:15:13 +04:00
parent da9b96de84
commit ed6d30ec42
5 changed files with 55 additions and 59 deletions

View File

@@ -32,9 +32,9 @@ object OwnHandControls {
private def myUnselectedCards(state: RoomStateView): List[String] = {
state.round match {
case RoundState.Voting(myCard, _) =>
case RoundStateView.Voting(myCard, _) =>
state.allowedCards.filterNot(value => myCard.contains(value))
case RoundState.Viewing(votes) =>
case RoundStateView.Viewing(votes) =>
state.allowedCards.filterNot(value => votes.toMap.get(state.me).contains(value))
}
}

View File

@@ -2,21 +2,19 @@ package industries.sunshine.planningpoker
import scala.scalajs.js
import com.raquo.laminar.api.L.{*, given}
import industries.sunshine.planningpoker.common.Models.RoundState
import industries.sunshine.planningpoker.common.Models.RoundStateView
import com.raquo.airstream.core.Signal
import industries.sunshine.planningpoker.common.Models.RoundState
import industries.sunshine.planningpoker.common.Models.RoundState
import io.laminext.fetch.Fetch
import scala.scalajs.js.Dynamic.{global => g}
import concurrent.ExecutionContext.Implicits.global
object TableControls {
def render(roundSignal: Signal[RoundState]): Element = {
def render(roundSignal: Signal[RoundStateView]): Element = {
div(
child <-- roundSignal.map {
case RoundState.Viewing(_) => newPollButton()
case RoundState.Voting(_, _) => endPollButton()
case RoundStateView.Viewing(_) => newPollButton()
case RoundStateView.Voting(_, _) => endPollButton()
}
)
}

View File

@@ -39,16 +39,16 @@ object TableView {
def getPlayerCardType(
id: PlayerID,
state: RoundState,
state: RoundStateView,
name: String,
myId: PlayerID
): CardState = {
state match {
case isOpen: RoundState.Voting =>
case isOpen: RoundStateView.Voting =>
if (myId == id) {
isOpen.myCard.fold(NoCard(name))(vote => Open(vote))
} else isOpen.alreadyVoted.find(_.id == id).fold(NoCard(name))(_ => CardBack)
case isClosed: RoundState.Viewing =>
} else isOpen.alreadyVoted.find(_ == id).fold(NoCard(name))(_ => CardBack)
case isClosed: RoundStateView.Viewing =>
isClosed.votes
.find(_._1 == id)
.fold {