Skip to content

Commit 448f6c8

Browse files
Anas12091101Asespinel
authored andcommitted
fix: loading unit page directly from link after logging in in Teak (openedx#2246)
This is a simple version of the fix for Teak; on master it was fixed with openedx#1867
1 parent 7e9b5c6 commit 448f6c8

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

  • src/course-unit/xblock-container-iframe

src/course-unit/xblock-container-iframe/index.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,16 @@ import { useIframeContent } from '../../generic/hooks/useIframeContent';
3737
import { useIframeMessages } from '../../generic/hooks/useIframeMessages';
3838
import VideoSelectorPage from '../../editors/VideoSelectorPage';
3939
import EditorPage from '../../editors/EditorPage';
40+
import { RequestStatus } from '../../data/constants';
4041

4142
const XBlockContainerIframe: FC<XBlockContainerIframeProps> = ({
42-
courseId, blockId, unitXBlockActions, courseVerticalChildren, handleConfigureSubmit, isUnitVerticalType,
43+
courseId,
44+
blockId,
45+
unitXBlockActions,
46+
courseVerticalChildren,
47+
handleConfigureSubmit,
48+
isUnitVerticalType,
49+
courseUnitLoadingStatus,
4350
}) => {
4451
const intl = useIntl();
4552
const dispatch = useDispatch();
@@ -70,6 +77,23 @@ const XBlockContainerIframe: FC<XBlockContainerIframeProps> = ({
7077
setIframeRef(iframeRef);
7178
}, [setIframeRef]);
7279

80+
useEffect(() => {
81+
const iframe = iframeRef?.current;
82+
if (!iframe) { return undefined; }
83+
84+
const handleIframeLoad = () => {
85+
if (courseUnitLoadingStatus.fetchUnitLoadingStatus === RequestStatus.FAILED) {
86+
window.location.reload();
87+
}
88+
};
89+
90+
iframe.addEventListener('load', handleIframeLoad);
91+
92+
return () => {
93+
iframe.removeEventListener('load', handleIframeLoad);
94+
};
95+
}, [iframeRef]);
96+
7397
const onXBlockSave = useCallback(/* istanbul ignore next */ () => {
7498
closeXBlockEditorModal();
7599
closeVideoSelectorModal();

0 commit comments

Comments
 (0)