From e9de31a2c48edf63c60584f3952b49ccde5d82c1 Mon Sep 17 00:00:00 2001 From: Stef Coenen Date: Thu, 24 Oct 2024 16:17:17 +0200 Subject: [PATCH] Added empty chat placeholder; Cleanup channel creation over peer; Fixed broken upload message for community owner; --- .../Message/CommunityMessageItem.tsx | 11 +---- .../Community/channel/CommunityHistory.tsx | 6 +-- .../community/messages/useCommunityMessage.ts | 3 ++ .../src/providers/CommunityMessageProvider.ts | 1 + .../src/providers/CommunityProvider.ts | 2 +- .../Community/CommunityChannelDetail.tsx | 47 +++++++++++++++---- 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/packages/community-app/src/components/Community/Message/CommunityMessageItem.tsx b/packages/community-app/src/components/Community/Message/CommunityMessageItem.tsx index ac72bcdd..4a1aa7f9 100644 --- a/packages/community-app/src/components/Community/Message/CommunityMessageItem.tsx +++ b/packages/community-app/src/components/Community/Message/CommunityMessageItem.tsx @@ -159,8 +159,6 @@ const CommunityTextMessageBody = ({ >
- {/* {content.replyId ? : null} */} - stringGuidsEqual(channel.fileMetadata.appData.uniqueId, tagGuid) @@ -217,7 +210,7 @@ const MessageTextRenderer = ({ if (hasChannel) { return ( #{attributes.value.trim()}{' '} diff --git a/packages/community-app/src/components/Community/channel/CommunityHistory.tsx b/packages/community-app/src/components/Community/channel/CommunityHistory.tsx index b3290e50..f70d3418 100644 --- a/packages/community-app/src/components/Community/channel/CommunityHistory.tsx +++ b/packages/community-app/src/components/Community/channel/CommunityHistory.tsx @@ -80,11 +80,7 @@ export const CommunityHistory = ({ }, [messages, origin]) || []; useEffect(() => { - if ( - setIsEmptyChat && - isFetched && - (!flattenedMsgs || flattenedMsgs?.filter((msg) => msg.fileId).length === 0) - ) + if (setIsEmptyChat && isFetched && (!flattenedMsgs || flattenedMsgs.length === 0)) setIsEmptyChat(true); }, [isFetched, flattenedMsgs]); diff --git a/packages/community-app/src/hooks/community/messages/useCommunityMessage.ts b/packages/community-app/src/hooks/community/messages/useCommunityMessage.ts index 31235192..206e9d39 100644 --- a/packages/community-app/src/hooks/community/messages/useCommunityMessage.ts +++ b/packages/community-app/src/hooks/community/messages/useCommunityMessage.ts @@ -226,6 +226,9 @@ export const useCommunityMessage = (props?: { ); } }, + onError: (err, messageParams) => { + console.error('Failed to update the chat message', err); + }, }), update: useMutation({ mutationFn: updateMessage, diff --git a/packages/community-app/src/providers/CommunityMessageProvider.ts b/packages/community-app/src/providers/CommunityMessageProvider.ts index 993848ea..e2110079 100644 --- a/packages/community-app/src/providers/CommunityMessageProvider.ts +++ b/packages/community-app/src/providers/CommunityMessageProvider.ts @@ -231,6 +231,7 @@ export const uploadCommunityMessage = async ( const recipientStatus = uploadResult.recipientStatus; if ( + recipientStatus && Object.values(recipientStatus).some( (status) => status.toString().toLowerCase() === TransferUploadStatus.EnqueuedFailed ) diff --git a/packages/community-app/src/providers/CommunityProvider.ts b/packages/community-app/src/providers/CommunityProvider.ts index 08a6d569..88d68a4e 100644 --- a/packages/community-app/src/providers/CommunityProvider.ts +++ b/packages/community-app/src/providers/CommunityProvider.ts @@ -143,7 +143,7 @@ export const saveCommunityChannel = async ( description: '', }); const uploadMetadata: UploadFileMetadata = { - allowDistribution: false, + allowDistribution: true, appData: { uniqueId: uniqueId, groupId: communityId, diff --git a/packages/community-app/src/templates/Community/CommunityChannelDetail.tsx b/packages/community-app/src/templates/Community/CommunityChannelDetail.tsx index 109a7c05..03e8b882 100644 --- a/packages/community-app/src/templates/Community/CommunityChannelDetail.tsx +++ b/packages/community-app/src/templates/Community/CommunityChannelDetail.tsx @@ -27,6 +27,7 @@ import { useMarkCommunityAsRead } from '../../hooks/community/useMarkCommunityAs import { CommunityCatchup } from '../../components/Community/CommunityCatchup'; export const CommunityChannelDetail = () => { + const [isEmtpyChannel, setIsEmptyChannel] = useState(false); const { odinKey, communityKey: communityId, channelKey: channelId, threadKey } = useParams(); const { data: community, isFetched } = useCommunity({ odinId: odinKey, communityId }).fetch; const navigate = useNavigate(); @@ -73,21 +74,27 @@ export const CommunityChannelDetail = () => {
- - navigate( - `${COMMUNITY_ROOT}/${odinKey}/${communityId}/${channelId}/${thread.fileMetadata.appData.uniqueId}/thread` - ) - } - /> + {isEmtpyChannel ? ( + + ) : ( + + navigate( + `${COMMUNITY_ROOT}/${odinKey}/${communityId}/${channelId}/${thread.fileMetadata.appData.uniqueId}/thread` + ) + } + setIsEmptyChat={setIsEmptyChannel} + /> + )} setIsEmptyChannel(false)} />
@@ -298,3 +305,25 @@ const CommunityThread = ({
); }; + +const EmptyChannel = ({ channel }: { channel: HomebaseFile | undefined }) => { + const { odinKey, communityKey } = useParams(); + + if (!channel) return null; + return ( +
+
+

# {channel.fileMetadata.appData.content?.title}

+ + @ + {' '} + {t('created this channel on')}{' '} + {formatDateExludingYearIfCurrent(new Date(channel.fileMetadata.created))} +

{channel.fileMetadata.appData.content?.description}

+
+
+ ); +};