Skip to content

Commit

Permalink
Last fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrsllwngr committed Feb 18, 2018
1 parent 8bc097e commit ed2b86d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
3 changes: 1 addition & 2 deletions fe/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},
"scripts": {
"start": "API_HOST=http://localhost:5000 webpack-dev-server --config webpack.config.js --devtool eval --progress --hot --host 0.0.0.0",
"mobile": "API_HOST=http://10.176.92.242:5000 webpack-dev-server --config webpack.config.js --devtool eval --progress --hot --host 0.0.0.0",
"timo": "API_HOST=http://10.180.61.219:5000 webpack-dev-server --config webpack.config.js --devtool eval --progress --hot"
"mobile": "API_HOST=http://10.176.92.242:5000 webpack-dev-server --config webpack.config.js --devtool eval --progress --hot --host 0.0.0.0"
}
}
20 changes: 9 additions & 11 deletions fe/frontend/src/main/scala/scalable/components/AdminTab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ object AdminTab {
var player: Option[Player] = Option.empty
var props: Props = _

var hasSong: Boolean = false


def onPlayerReady(e: Event): js.UndefOr[(Event) => Any] = {
e.target.whenDefined(p => { p.playVideo()
Expand All @@ -48,13 +50,13 @@ object AdminTab {
}

def resolveNext(player: Player): Unit = {
println("resolve")

val state = props.proxy.modelReader.apply()
var songList = state.songList.filter(s => s.playState.equals("QUEUE"))
if (songList.isEmpty) {
songList = scala.util.Random.shuffle(state.songList)
}
player.hasSong = true
hasSong = true
if (songList.nonEmpty) props.proxy.value.partyId match {
case Some(id) => loadSong(player, songList.head, id)
case None => println("No Party ID")
Expand All @@ -68,7 +70,6 @@ object AdminTab {
}

def onPlayerStateChange(e: Event): js.UndefOr[(Event) => Any] = {
println("state Change")
e.target.whenDefined(p => {
println(s"state ${p.getPlayerState()}")
p.getPlayerState() match {
Expand All @@ -92,7 +93,6 @@ object AdminTab {
}

def unmounted: Callback = Callback {
println("Unmounted")
js.timers.clearInterval(timer)
}

Expand All @@ -106,10 +106,10 @@ object AdminTab {
props.proxy.value.partyId match {
case Some(id) => RestService.getSongs(id).map { songs => {
AppCircuit.dispatch(SetSongsForParty(songs))
if (songs.nonEmpty && player.isDefined) {
if(!player.get.hasSong) resolveNext(player.get)
} else if (songs.isEmpty && player.isDefined){
if(player.get.hasSong) player.get.hasSong = false
if (songs.nonEmpty && player.isDefined && !hasSong) {
resolveNext(player.get)
} else if (songs.isEmpty && player.isDefined && hasSong){
hasSong = false
}
}
}
Expand All @@ -118,7 +118,6 @@ object AdminTab {
}

def createPlayer(): Unit = {
println("create player")
val tag = org.scalajs.dom.document.createElement("script").asInstanceOf[org.scalajs.dom.html.Script]
tag.src = "https://www.youtube.com/iframe_api"
val firstScriptTag = org.scalajs.dom.document.getElementsByTagName("script").item(0)
Expand All @@ -145,8 +144,7 @@ object AdminTab {
def render(p: Props): VdomTagOf[Div] = {
val proxy = p.proxy()
props = p
if(player.isEmpty)
createPlayer()
createPlayer()
var roomCode: String = "NO PARTY ID"
p.proxy.value.partyId match {
case Some(id) => roomCode = id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ object AlreadyPlayedComp {
),
<.div( // Child 2 Song title
<.pre(
^.cls := "h6 mb-0 text-secondary",
"ALREADY PLAYED"),
^.cls := "h6 mb-0 text-secondary", ^.verticalAlign := "text-top",
"ALREADY PLAYED ",
<.span(^.cls := "badge badge-secondary",^.verticalAlign := "top" , song.upvotes - song.downvotes )),
^.flex := "1 1 auto",
^.cls := "h3 mb-0 mr-2 text-truncate",
name,<.pre(
Expand Down
2 changes: 0 additions & 2 deletions fe/frontend/src/main/scala/scalable/components/Layout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ object Layout {
<.div(
<.div(
^.cls := "blurBg"
//TODO Background
),
<.div(^.cls := "container", props.resolution.render())
//TODO
)
}
}
Expand Down
4 changes: 0 additions & 4 deletions fe/frontend/src/main/scala/scalable/models/Player.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ import scala.scalajs.js.annotation._
@JSGlobal("YT.Player")
class Player protected() extends js.Object {

var hasSong: Boolean = false

def this(divId:String, settings:PlayerOptions) = this()

//https://developers.google.com/youtube/iframe_api_reference?hl=en#Playback_controls
Expand All @@ -127,10 +125,8 @@ import scala.scalajs.js.annotation._
def loadVideoById(opts:VideoIdStartOptions):Unit = js.native
def cueVideoById(videoId:String,startSeconds:Double,suggestedQuality:String):Unit = js.native
def cueVideoById(opts:VideoIdStartOptions):Unit = js.native
// TODO: obj syntax
def cueVideoByUrl(mediaContentUrl:String,startSeconds:Double,suggestedQuality:String):Unit = js.native
def loadVideoByUrl(mediaContentUrl:String,startSeconds:Double,suggestedQuality:String):Unit = js.native
// TODO: ...

// controls
def playVideo():Unit = js.native
Expand Down

0 comments on commit ed2b86d

Please sign in to comment.