 onSubscribe = ->
   $(".nLoading").css({display: "none"})
   gameId = $.url().param("game_id")
+
+  Meteor.autorun ->
+    setUrl(Session.get("gameId"))
+
   if gameId
     game = noughts.Games.findOne(gameId)
     displayError("Game not found for gameId: " + gameId) unless game

handleNewGameClick = ->
  Meteor.call "newGame", Meteor.userId(), (err, gameId) ->
    if err then throw err
    window.history.pushState({}, "", "?game_id=#{gameId}")
    showInviteDialog (inviteResponse) ->
      return if not inviteResponse
      invitedUser = inviteResponse.to[0]

    message: "Want to play some Noughts?", inviteCallback

displayNotice = (msg) -> $(".nNotification").text(msg)

setUrl = (gameId=null) ->
  if gameId
    window.history.pushState({}, "",
        "?user_id=#{Meteor.userId()}&game_id=#{gameId}")
  else
    window.history.pushState({}, "",
        "?user_id=#{Meteor.userId()}")

PlayScreen = me.ScreenObject.extend
  handleClick_: (tile) ->
