From 800407f9563d54e29ec9846370903f6a44483abe Mon Sep 17 00:00:00 2001 From: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com> Date: Tue, 5 Nov 2024 05:32:00 +0530 Subject: [PATCH] Fixed a bug where non-admin user wasn't able to edit their scheduled post (#29084) --- webapp/channels/src/components/edit_post/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webapp/channels/src/components/edit_post/index.ts b/webapp/channels/src/components/edit_post/index.ts index 9c85116534..55ba6fe893 100644 --- a/webapp/channels/src/components/edit_post/index.ts +++ b/webapp/channels/src/components/edit_post/index.ts @@ -37,25 +37,26 @@ type Props = { function mapStateToProps(state: GlobalState, props: Props) { const config = getConfig(state); + const currentUserId = getCurrentUserId(state); let editingPost; let channelId: string; let draft; + let isAuthor; if (props.scheduledPost) { editingPost = {post: null}; channelId = props.scheduledPost.channel_id; draft = getPostDraft(state, StoragePrefixes.EDIT_DRAFT, props.scheduledPost.id); + isAuthor = true; } else { editingPost = getEditingPost(state); channelId = editingPost.post.channel_id; draft = getPostDraft(state, StoragePrefixes.EDIT_DRAFT, editingPost.postId); + isAuthor = editingPost?.post?.user_id === currentUserId; } - const currentUserId = getCurrentUserId(state); const teamId = getCurrentTeamId(state); - - const isAuthor = editingPost?.post?.user_id === currentUserId; const deletePermission = isAuthor ? Permissions.DELETE_POST : Permissions.DELETE_OTHERS_POSTS; const editPermission = isAuthor ? Permissions.EDIT_POST : Permissions.EDIT_OTHERS_POSTS;