Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/discussions/posts/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const postThread = async (
content,
{
following,
cohort,
groupId,
anonymous,
anonymousToPeers,
notifyAllLearners,
Expand All @@ -114,7 +114,7 @@ export const postThread = async (
following,
anonymous,
anonymousToPeers,
groupId: cohort,
groupId,
enableInContextSidebar,
notifyAllLearners,
captchaToken: recaptchaToken,
Expand Down Expand Up @@ -154,6 +154,7 @@ export const updateThread = async (threadId, {
pinned,
editReasonCode,
closeReasonCode,
groupId,
} = {}) => {
const url = `${getThreadsApiUrl()}${threadId}/`;
const patchData = snakeCaseObject({
Expand All @@ -169,6 +170,7 @@ export const updateThread = async (threadId, {
pinned,
editReasonCode,
closeReasonCode,
groupId,
});
const { data } = await getAuthenticatedHttpClient()
.patch(url, patchData, { headers: { 'Content-Type': 'application/merge-patch+json' } });
Expand Down
11 changes: 7 additions & 4 deletions src/discussions/posts/data/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export function createNewThread({
following,
anonymous,
anonymousToPeers,
cohort,
groupId,
enableInContextSidebar,
notifyAllLearners,
recaptchaToken,
Expand All @@ -224,12 +224,12 @@ export function createNewThread({
following,
anonymous,
anonymousToPeers,
cohort,
groupId,
notifyAllLearners,
recaptchaToken,
}));
const data = await postThread(courseId, topicId, type, title, content, {
cohort,
groupId,
following,
anonymous,
anonymousToPeers,
Expand All @@ -252,7 +252,8 @@ export function createNewThread({
}

export function updateExistingThread(threadId, {
flagged, voted, read, topicId, type, title, content, following, closed, pinned, closeReasonCode, editReasonCode,
flagged, voted, read, topicId, type, title, content, following,
closed, pinned, closeReasonCode, editReasonCode, groupId,
}) {
return async (dispatch) => {
try {
Expand All @@ -270,6 +271,7 @@ export function updateExistingThread(threadId, {
pinned,
editReasonCode,
closeReasonCode,
groupId,
}));
const data = await updateThread(threadId, {
flagged,
Expand All @@ -284,6 +286,7 @@ export function updateExistingThread(threadId, {
pinned,
editReasonCode,
closeReasonCode,
groupId,
});
dispatch(updateThreadSuccess(camelCaseObject(data)));
} catch (error) {
Expand Down
9 changes: 5 additions & 4 deletions src/discussions/posts/post-editor/PostEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const PostEditor = ({
notifyAllLearners: false,
anonymous: allowAnonymous ? false : undefined,
anonymousToPeers: allowAnonymousToPeers ? false : undefined,
cohort: post?.cohort || 'default',
cohort: post?.groupId || 'default',
editReasonCode: post?.lastEdit?.reasonCode || (
userIsStaff && canDisplayEditReason ? 'violates-guidelines' : undefined
),
Expand Down Expand Up @@ -175,6 +175,8 @@ const PostEditor = ({

const submitForm = useCallback(async (values, { resetForm }) => {
let recaptchaToken;
const groupId = canSelectCohort(values.topic) ? selectedCohort(values.cohort) : undefined;

if (shouldRequireCaptcha && executeRecaptcha) {
try {
recaptchaToken = await executeRecaptcha('submit_post');
Expand All @@ -196,10 +198,9 @@ const PostEditor = ({
title: values.title,
content: values.comment,
editReasonCode: values.editReasonCode || undefined,
groupId,
}));
} else {
const cohort = canSelectCohort(values.topic) ? selectedCohort(values.cohort) : undefined;

await dispatchSubmit(createNewThread({
courseId,
topicId: values.topic,
Expand All @@ -209,7 +210,7 @@ const PostEditor = ({
following: values.follow,
anonymous: allowAnonymous ? values.anonymous : undefined,
anonymousToPeers: allowAnonymousToPeers ? values.anonymousToPeers : undefined,
cohort,
groupId,
enableInContextSidebar,
notifyAllLearners: values.notifyAllLearners,
...(shouldRequireCaptcha && recaptchaToken ? { recaptchaToken } : {}),
Expand Down