PurpleKingdomGames / tyrian

Elm-inspired Scala UI library.
https://tyrian.indigoengine.io/
MIT License
346 stars 26 forks source link

Router is called twice on chromium-based browsers after refresh (F5) #262

Open mprevel opened 5 months ago

mprevel commented 5 months ago

Hi,

It seems that the router is called twice after refreshing (F5) a page on chromium-based browsers (reproduced with chromium, chrome and brave on linux, but behaves as expected with Firefox). It implies a duplication of the messages and commands that may be produced by the update function that handles the message from the router.

Adding a println allows to highlight the behavior.

  val routes: Location => Msg = {
    case loc: Location.Internal =>
      println(s"Router Internal Location: $loc")
      loc.hash.getOrElse("#/").drop(1) match
        case "/"               => Msg.NavigateTo(Page.Home)
        case _                 => Msg.NoOp

    case loc: Location.External =>
      println(s"Router Location External: $loc")
  }