fix: Display service banner after login (#5594)

This commit is contained in:
Bruno Quaresma
2023-01-05 18:10:15 -03:00
committed by GitHub
parent 8ee3e2c541
commit 0d30a1eb72
2 changed files with 12 additions and 4 deletions

View File

@ -1,15 +1,23 @@
import { useActor } from "@xstate/react"
import { useContext } from "react"
import { useContext, useEffect } from "react"
import { XServiceContext } from "xServices/StateContext"
import { ServiceBannerView } from "./ServiceBannerView"
export const ServiceBanner: React.FC = () => {
const xServices = useContext(XServiceContext)
const [appearanceState] = useActor(xServices.appearanceXService)
const [appearanceState, appearanceSend] = useActor(
xServices.appearanceXService,
)
const [authState] = useActor(xServices.authXService)
const { message, background_color, enabled } =
appearanceState.context.appearance.service_banner
useEffect(() => {
if (authState.matches("signedIn")) {
appearanceSend("GET_APPEARANCE")
}
}, [appearanceSend, authState])
if (!enabled) {
return null
}

View File

@ -50,7 +50,7 @@ export const appearanceMachine = createMachine(
appearance: emptyAppearance,
preview: false,
},
initial: "gettingAppearance",
initial: "idle",
states: {
idle: {
on: {