@@ -34,6 +34,8 @@ interface IterableAppProps {
3434 initialize : ( navigation : Navigation ) => void ;
3535 /** Whether the SDK has been initialized */
3636 isInitialized ?: boolean ;
37+ /** Is the tab in focus the `Inbox` tab? */
38+ isInboxTab : boolean ;
3739 /** Whether the user is logged in */
3840 isLoggedIn ?: boolean ;
3941 /**
@@ -45,10 +47,16 @@ interface IterableAppProps {
4547 loginInProgress ?: boolean ;
4648 /** Logs the user out */
4749 logout : ( ) => void ;
50+ /** TODO: Ask @evantk91 or @Ayyanchira what this is for */
51+ returnToInboxTrigger : boolean ;
4852 /** Sets the API key for the user */
4953 setApiKey : ( value : string ) => void ;
54+ /** Sets whether the tab in focus is the `Inbox` tab */
55+ setIsInboxTab : ( value : boolean ) => void ;
5056 /** Sets whether the login is in progress */
5157 setLoginInProgress : ( value : boolean ) => void ;
58+ /** TODO: Ask @evantk91 or @Ayyanchira what this is for */
59+ setReturnToInboxTrigger : ( value : boolean ) => void ;
5260 /** Sets the user ID for the user */
5361 setUserId : ( value : string ) => void ;
5462 /** The user ID for the user */
@@ -59,13 +67,17 @@ const IterableAppContext = createContext<IterableAppProps>({
5967 apiKey : undefined ,
6068 config : null ,
6169 initialize : ( ) => undefined ,
70+ isInboxTab : false ,
6271 isInitialized : false ,
6372 isLoggedIn : false ,
6473 login : ( ) => undefined ,
6574 loginInProgress : false ,
6675 logout : ( ) => undefined ,
76+ returnToInboxTrigger : false ,
6777 setApiKey : ( ) => undefined ,
78+ setIsInboxTab : ( ) => undefined ,
6879 setLoginInProgress : ( ) => undefined ,
80+ setReturnToInboxTrigger : ( ) => undefined ,
6981 setUserId : ( ) => undefined ,
7082 userId : undefined ,
7183} ) ;
@@ -75,6 +87,9 @@ const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
7587export const IterableAppProvider : FunctionComponent <
7688 React . PropsWithChildren < unknown >
7789> = ( { children } ) => {
90+ const [ returnToInboxTrigger , setReturnToInboxTrigger ] =
91+ useState < boolean > ( false ) ;
92+ const [ isInboxTab , setIsInboxTab ] = useState < boolean > ( false ) ;
7893 const [ itblConfig , setItblConfig ] = useState < IterableConfig | null > ( null ) ;
7994 const [ isLoggedIn , setIsLoggedIn ] = useState < boolean > ( false ) ;
8095 const [ isInitialized , setIsInitialized ] = useState < boolean > ( false ) ;
@@ -110,7 +125,7 @@ export const IterableAppProvider: FunctionComponent<
110125 config . inAppDisplayInterval = 1.0 ; // Min gap between in-apps. No need to set this in production.
111126
112127 config . urlHandler = ( url : string ) => {
113- const routeNames = [ Route . User ] ;
128+ const routeNames = [ Route . Inbox , Route . User ] ;
114129 for ( const route of routeNames ) {
115130 if ( url . includes ( route . toLowerCase ( ) ) ) {
116131 // TODO: Figure out typing for this
@@ -191,13 +206,17 @@ export const IterableAppProvider: FunctionComponent<
191206 apiKey,
192207 config : itblConfig ,
193208 initialize,
209+ isInboxTab,
194210 isInitialized,
195211 isLoggedIn,
196212 login,
197213 loginInProgress,
198214 logout,
215+ returnToInboxTrigger,
199216 setApiKey,
217+ setIsInboxTab,
200218 setLoginInProgress,
219+ setReturnToInboxTrigger,
201220 setUserId,
202221 userId,
203222 } }
0 commit comments