diff --git a/src/Analysis/AnalysisApp.jsx b/src/Analysis/AnalysisApp.jsx index 1d17c6e60a..c3d36cb1ae 100644 --- a/src/Analysis/AnalysisApp.jsx +++ b/src/Analysis/AnalysisApp.jsx @@ -9,6 +9,7 @@ import HIVCohortFilter from '../HIVCohortFilter/HIVCohortFilter'; import ReduxGWASUIApp from './GWASUIApp/ReduxGWASUIApp'; import { analysisApps } from '../localconf'; import './AnalysisApp.css'; +import sessionMonitor from '../SessionMonitor'; const queryClient = new QueryClient(); @@ -52,6 +53,21 @@ class AnalysisApp extends React.Component { queryClient.invalidateQueries('workflows'); } + processAppMessages = (event) => { + const pathArray = this.state.app.applicationUrl.split( '/' ); + const protocol = pathArray[0]; + const host = pathArray[2]; + const applicationBaseUrl = protocol + '//' + host; + + // ONLY process messages coming from the same domain as the app AND + // which contain the message "refresh token!": + if (event.origin === applicationBaseUrl && + event.data === "refresh token!") { + //Call function to refresh session: + sessionMonitor.updateUserActivity(); + } + } + getAppContent = (app) => { switch (app) { case 'vaGWAS': @@ -84,6 +100,8 @@ class AnalysisApp extends React.Component { ); default: + // this will ensure the main window will process the app messages (if any): + window.addEventListener("message", this.processAppMessages); return (