File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { useActor } from "@xstate/react"
2
- import { useContext } from "react"
2
+ import { useContext , useEffect } from "react"
3
3
import { XServiceContext } from "xServices/StateContext"
4
4
import { ServiceBannerView } from "./ServiceBannerView"
5
5
6
6
export const ServiceBanner : React . FC = ( ) => {
7
7
const xServices = useContext ( XServiceContext )
8
- const [ appearanceState ] = useActor ( xServices . appearanceXService )
9
-
8
+ const [ appearanceState , appearanceSend ] = useActor (
9
+ xServices . appearanceXService ,
10
+ )
11
+ const [ authState ] = useActor ( xServices . authXService )
10
12
const { message, background_color, enabled } =
11
13
appearanceState . context . appearance . service_banner
12
14
15
+ useEffect ( ( ) => {
16
+ if ( authState . matches ( "signedIn" ) ) {
17
+ appearanceSend ( "GET_APPEARANCE" )
18
+ }
19
+ } , [ appearanceSend , authState ] )
20
+
13
21
if ( ! enabled ) {
14
22
return null
15
23
}
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ export const appearanceMachine = createMachine(
50
50
appearance : emptyAppearance ,
51
51
preview : false ,
52
52
} ,
53
- initial : "gettingAppearance " ,
53
+ initial : "idle " ,
54
54
states : {
55
55
idle : {
56
56
on : {
You can’t perform that action at this time.
0 commit comments