Skip to content

Commit

Permalink
Merge pull request #1211 from gemini-hlsw/bump-sjsreact
Browse files Browse the repository at this point in the history
Upgrade scalajs-react
  • Loading branch information
rpiaggio authored Jul 11, 2024
2 parents 9929cdd + b80d374 commit 174950e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 39 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ val Versions = new {
val monocle = "3.2.0"
val mouse = "1.3.1"
val pprint = "0.9.0"
val scalaJsReact = "3.0.0-beta3"
val scalaJsReact = "3.0.0-beta5"
}

ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("snapshots")
Expand Down
66 changes: 32 additions & 34 deletions modules/ui/src/main/scala/lucuma/ui/components/state/IfLogged.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,40 @@ object IfLogged:
private type Props[E] = IfLogged[E]

private def componentBuilder[E] =
ScalaFnComponent
.withHooks[Props[E]]
.render: props =>
import props.given
ScalaFnComponent[Props[E]]: props =>
import props.given

val vaultSet = props.userVault.async.set
val messageSet = props.userSelectionMessage.async.set.compose((_: NonEmptyString).some)
val vaultSet = props.userVault.async.set
val messageSet = props.userSelectionMessage.async.set.compose((_: NonEmptyString).some)

props.userVault.get.fold[VdomElement](
UserSelectionForm(
props.systemName,
props.systemNameStyle,
props.ssoClient,
props.userVault,
props.userSelectionMessage,
props.allowGuest
props.userVault.get.fold[VdomElement](
UserSelectionForm(
props.systemName,
props.systemNameStyle,
props.ssoClient,
props.userVault,
props.userSelectionMessage,
props.allowGuest
)
) { vault =>
React.Fragment(
SSOManager(props.ssoClient, vault.expiration, vaultSet, messageSet),
ConnectionManager(
vault,
props.openConnections,
props.closeConnections,
props.onConnect
)(
LogoutTracker(
vaultSet,
messageSet,
props.channelName,
props.isLogoutEvent,
props.getEventNonce,
props.createEventWithNonce
)(props.render(_))
)
) { vault =>
React.Fragment(
SSOManager(props.ssoClient, vault.expiration, vaultSet, messageSet),
ConnectionManager(
vault,
props.openConnections,
props.closeConnections,
props.onConnect
)(
LogoutTracker(
vaultSet,
messageSet,
props.channelName,
props.isLogoutEvent,
props.getEventNonce,
props.createEventWithNonce
)(props.render(_))
)
)
}
)
}

private val component = componentBuilder[Any]
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ object SSOManager:
private val component =
ScalaFnComponent
.withHooks[Props]
// Needed because of the infamous bug where useEffect doesn't run if it's the only hook.
.useState(())
.useEffectStreamWithDepsBy((props, _) => props.expiration): (props, _) =>
.useEffectStreamWithDepsBy(props => props.expiration): props =>
expiration =>
import props.given

Expand All @@ -66,4 +64,4 @@ object SSOManager:
yield ())
.onError: t =>
Logger[DefaultA].error(t)("Error refreshing user token") >> props.setVault(none)
.render((_, _) => EmptyVdom) // This is a "phantom" component. Doesn't render anything.
.render(_ => EmptyVdom) // This is a "phantom" component. Doesn't render anything.

0 comments on commit 174950e

Please sign in to comment.