From b5912c14d839524664ca932b4c5ee1353daece65 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Mon, 29 Jul 2024 20:56:34 +0700 Subject: [PATCH] Update approved status after set approved event is received --- src/components/chats/ChatList/ChatItemContainer.tsx | 7 ------- src/services/datahub/events/subscription.tsx | 11 +++++++++++ src/services/datahub/posts/subscription.tsx | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/chats/ChatList/ChatItemContainer.tsx b/src/components/chats/ChatList/ChatItemContainer.tsx index 5468834d9..72ba4107a 100644 --- a/src/components/chats/ChatList/ChatItemContainer.tsx +++ b/src/components/chats/ChatList/ChatItemContainer.tsx @@ -2,7 +2,6 @@ import useIsMessageBlocked from '@/hooks/useIsMessageBlocked' import usePrevious from '@/hooks/usePrevious' import { getPostQuery } from '@/services/api/query' import { useMessageData } from '@/stores/message' -import { useMyMainAddress } from '@/stores/my-account' import { cx } from '@/utils/class-names' import { useQueryClient } from '@tanstack/react-query' import { ComponentProps, forwardRef, useEffect } from 'react' @@ -42,16 +41,10 @@ function ChatItemContainer( const { content } = message const { body, extensions } = content || {} - const myAddress = useMyMainAddress() if ((isMessageBlocked && !showBlockedMessage) || (!body && !extensions)) return null - const ownerId = message.struct.ownerId - const senderAddress = ownerId ?? '' - - const isMyMessage = myAddress === senderAddress - return (
{ + if (!oldData) return oldData + return { + ...oldData, + struct: { + ...oldData.struct, + approvedInRootPost: newStatus, + }, + } + }) return } diff --git a/src/services/datahub/posts/subscription.tsx b/src/services/datahub/posts/subscription.tsx index 6445b1211..ccc3a48a6 100644 --- a/src/services/datahub/posts/subscription.tsx +++ b/src/services/datahub/posts/subscription.tsx @@ -157,6 +157,7 @@ async function processMessage( ...dataFromEntityId, struct: { ...dataFromEntityId.struct, + approvedInRootPost: eventData.entity.approvedInRootPost, approvedInRootPostAtTime: eventData.entity.approvedInRootPostAtTime, dataType: eventData.entity.dataType, },