feat: Add post actions dropdown menu
Adds a dropdown menu for comments and posts to perform actions like pinning, unpinning, reporting etc.
This commit is contained in:
@@ -98,6 +98,8 @@ export async function postThread(courseId, topicId, type, title, content, follow
|
||||
* @param {boolean} voted
|
||||
* @param {boolean} read
|
||||
* @param {boolean} following
|
||||
* @param {boolean} closed
|
||||
* @param {boolean} pinned
|
||||
* @returns {Promise<{}>}
|
||||
*/
|
||||
export async function updateThread(threadId, {
|
||||
@@ -109,6 +111,8 @@ export async function updateThread(threadId, {
|
||||
title,
|
||||
content,
|
||||
following,
|
||||
closed,
|
||||
pinned,
|
||||
} = {}) {
|
||||
const url = `${threadsApiUrl}${threadId}/`;
|
||||
const patchData = snakeCaseObject({
|
||||
@@ -120,6 +124,8 @@ export async function updateThread(threadId, {
|
||||
title,
|
||||
raw_body: content,
|
||||
following,
|
||||
closed,
|
||||
pinned,
|
||||
});
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.patch(url, patchData, { headers: { 'Content-Type': 'application/merge-patch+json' } });
|
||||
|
||||
@@ -48,5 +48,5 @@ export const selectThreadSorting = () => state => state.threads.sortedBy;
|
||||
export const selectThreadFilters = () => state => state.threads.filters;
|
||||
|
||||
export const selectAuthorAvatars = author => state => (
|
||||
state.threads.avatars?.[author].profile.image
|
||||
state.threads.avatars?.[author]?.profile.image
|
||||
);
|
||||
|
||||
@@ -125,23 +125,23 @@ const threadsSlice = createSlice({
|
||||
},
|
||||
setSortedBy: (state, { payload }) => {
|
||||
state.sortedBy = payload;
|
||||
state.pages = {};
|
||||
state.pages = [];
|
||||
},
|
||||
setStatusFilter: (state, { payload }) => {
|
||||
state.filters.status = payload;
|
||||
state.pages = {};
|
||||
state.pages = [];
|
||||
},
|
||||
setAllPostsTypeFilter: (state, { payload }) => {
|
||||
state.filters.allPosts = payload;
|
||||
state.pages = {};
|
||||
state.pages = [];
|
||||
},
|
||||
setMyPostsTypeFilter: (state, { payload }) => {
|
||||
state.filters.myPosts = payload;
|
||||
state.pages = {};
|
||||
state.pages = [];
|
||||
},
|
||||
setSearchQuery: (state, { payload }) => {
|
||||
state.filters.search = payload;
|
||||
state.pages = {};
|
||||
state.pages = [];
|
||||
},
|
||||
showPostEditor: (state) => {
|
||||
state.postEditorVisible = true;
|
||||
|
||||
@@ -187,7 +187,7 @@ export function createNewThread({
|
||||
}
|
||||
|
||||
export function updateExistingThread(threadId, {
|
||||
flagged, voted, read, topicId, type, title, content, following,
|
||||
flagged, voted, read, topicId, type, title, content, following, closed, pinned,
|
||||
}) {
|
||||
return async (dispatch) => {
|
||||
try {
|
||||
@@ -201,6 +201,8 @@ export function updateExistingThread(threadId, {
|
||||
title,
|
||||
content,
|
||||
following,
|
||||
closed,
|
||||
pinned,
|
||||
}));
|
||||
const data = await updateThread(threadId, {
|
||||
flagged,
|
||||
@@ -211,6 +213,8 @@ export function updateExistingThread(threadId, {
|
||||
title,
|
||||
content,
|
||||
following,
|
||||
closed,
|
||||
pinned,
|
||||
});
|
||||
dispatch(updateThreadSuccess(camelCaseObject(data)));
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user