Skip to content

Commit

Permalink
fix: should not fetch courseTopics for lti provider (openedx#1165)
Browse files Browse the repository at this point in the history
* fix: should not fetch courseTopics for lti provider

* refactor: fetch course topics when provider is edx
  • Loading branch information
awais-ansari authored Aug 22, 2023
1 parent ea2d7ed commit 2e90e21
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { Icon } from '@edx/paragon';
import { QuestionAnswer } from '@edx/paragon/icons';
import PropTypes from 'prop-types';
import React, { useContext, useEffect } from 'react';
import React, { useContext, useEffect, useMemo } from 'react';
import { useDispatch } from 'react-redux';
import { useModel } from '../../../../../generic/model-store';
import { getCourseDiscussionTopics } from '../../../../data/thunks';
Expand All @@ -23,12 +23,16 @@ const DiscussionsTrigger = ({
courseId,
} = useContext(SidebarContext);
const dispatch = useDispatch();
const { tabs } = useModel('courseHomeMeta', courseId);
const topic = useModel('discussionTopics', unitId);
const baseUrl = getConfig().DISCUSSIONS_MFE_BASE_URL;
const edxProvider = useMemo(
() => tabs?.find(tab => tab.slug === 'discussion'),
[tabs],
);

useEffect(() => {
// Only fetch the topic data if the MFE is configured.
if (baseUrl) {
if (baseUrl && edxProvider) {
dispatch(getCourseDiscussionTopics(courseId));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down

0 comments on commit 2e90e21

Please sign in to comment.