From a5b439188cb6bbaa18e83510ef847963c4490366 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Tue, 23 Jul 2024 02:11:16 +0700 Subject: [PATCH] Fix auto approve wrong checker --- src/components/chats/ChatItem/ChatItemMenus.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/chats/ChatItem/ChatItemMenus.tsx b/src/components/chats/ChatItem/ChatItemMenus.tsx index 52b94d9b3..54f12b3c1 100644 --- a/src/components/chats/ChatItem/ChatItemMenus.tsx +++ b/src/components/chats/ChatItem/ChatItemMenus.tsx @@ -86,6 +86,9 @@ export default function ChatItemMenus({ getSocialProfileQuery.useQuery(ownerId, { enabled: inView && isAdmin, }) + const isVerifiedUser = + socialProfile?.allowedCreateCommentRootPostIds.includes(chatId) + const { mutate: approveUser } = useApproveUser() const setMessageToEdit = useMessageData((state) => state.setMessageToEdit) const openExtensionModal = useExtensionData( @@ -128,18 +131,16 @@ export default function ChatItemMenus({ if (isMessageOwner && !isOptimisticMessage) { menus.unshift(hideMenu) - const approvedTime = message?.struct.approvedInRootPostAtTime const createdTime = message?.struct.createdAtTime const isApproved = message?.struct.approvedInRootPost - const isAutoApproved = isApproved && approvedTime === createdTime const isAfter5MinsOfCreation = dayjs(createdTime).diff(dayjs(), 'minute') < 5 if ( (message?.content?.body.trim().length ?? 0) > 0 && - ((!isAutoApproved && isAfter5MinsOfCreation && !isApproved) || - (isAutoApproved && isAfter5MinsOfCreation)) + ((!isVerifiedUser && isAfter5MinsOfCreation && !isApproved) || + (isVerifiedUser && isAfter5MinsOfCreation)) ) menus.unshift(editItem) } @@ -187,10 +188,7 @@ export default function ChatItemMenus({ }) }, }) - if ( - !loadingSocialProfile && - !socialProfile?.allowedCreateCommentRootPostIds.includes(chatId) - ) { + if (!loadingSocialProfile && !isVerifiedUser) { menus.unshift({ text: 'Approve User', icon: FaCheck,