From 2e90e214b460a2b05d0c6a1ffb5f5a6192e3cd34 Mon Sep 17 00:00:00 2001 From: Awais Ansari <79941147+awais-ansari@users.noreply.github.com> Date: Tue, 22 Aug 2023 12:44:31 +0500 Subject: [PATCH] fix: should not fetch courseTopics for lti provider (#1165) * fix: should not fetch courseTopics for lti provider * refactor: fetch course topics when provider is edx --- .../sidebars/discussions/DiscussionsTrigger.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/courseware/course/sidebar/sidebars/discussions/DiscussionsTrigger.jsx b/src/courseware/course/sidebar/sidebars/discussions/DiscussionsTrigger.jsx index ef4b9944d7..4a49ee986d 100644 --- a/src/courseware/course/sidebar/sidebars/discussions/DiscussionsTrigger.jsx +++ b/src/courseware/course/sidebar/sidebars/discussions/DiscussionsTrigger.jsx @@ -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'; @@ -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