Skip to content

Commit fe6639c

Browse files
feat: added process to sync discussions topic on page load
1 parent 9a2dc80 commit fe6639c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/course-outline/data/api.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ export async function getCourseOutlineIndex(courseId) {
5959
return camelCaseObject(data);
6060
}
6161

62+
/**
63+
*
64+
* @param courseId
65+
* @returns {Promise<Array|Object>}
66+
*/
67+
export async function createDiscussionsTopics(courseId) {
68+
const { data } = await getAuthenticatedHttpClient()
69+
.post(`${getApiBaseUrl()}/api/discussions/v0/course/${courseId}/sync_discussion_topics`);
70+
return camelCaseObject(data);
71+
}
72+
6273
/**
6374
* Get course best practices.
6475
* @param {{courseId: string, excludeGraded: boolean, all: boolean}} options

src/course-outline/data/thunk.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
setVideoSharingOption,
3131
setCourseItemOrderList,
3232
pasteBlock,
33-
dismissNotification,
33+
dismissNotification, createDiscussionsTopics,
3434
} from './api';
3535
import {
3636
addSection,
@@ -92,6 +92,12 @@ export function fetchCourseOutlineIndexQuery(courseId) {
9292
}));
9393
}
9494
}
95+
// Sync discussions topics and log errors if any because we don't want to interrupt the process.
96+
try {
97+
await createDiscussionsTopics(courseId);
98+
} catch (error) {
99+
console.log(error);
100+
}
95101
};
96102
}
97103

0 commit comments

Comments
 (0)