Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FE render system messages for new feed item with link #2014 #2018

Merged
merged 15 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/pages/common/components/ChatComponent/ChatComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ interface ChatComponentInterface {
governanceCircles?: Circles;
commonMember: CommonMember | null;
hasAccess?: boolean;
discussion: Discussion;
discussion?: Discussion;
chatChannel?: ChatChannel;
lastSeenItem?: CommonFeedObjectUserUnique["lastSeen"];
feedItemId: string;
Expand All @@ -91,6 +91,7 @@ interface ChatComponentInterface {
isJoinPending?: boolean;
onJoinCommon?: () => void;
onUserClick?: (userId: string) => void;
onFeedItemClick?: (feedItemId: string) => void;
}

interface Messages {
Expand Down Expand Up @@ -131,6 +132,7 @@ export default function ChatComponent({
isJoinPending = false,
onJoinCommon,
onUserClick,
onFeedItemClick,
}: ChatComponentInterface) {
const dispatch = useDispatch();
useZoomDisabling();
Expand All @@ -142,7 +144,7 @@ export default function ChatComponent({
);
const user = useSelector(selectUser());
const userId = user?.uid;
const discussionId = discussion.id;
const discussionId = discussion?.id || "";
const isChatChannel = Boolean(chatChannel);

const hasPermissionToHide =
Expand Down Expand Up @@ -204,9 +206,9 @@ export default function ChatComponent({

useEffect(() => {
if (commonId && !isChatChannel) {
fetchDiscussionUsers(commonId, discussion.circleVisibility);
fetchDiscussionUsers(commonId, discussion?.circleVisibility);
}
}, [commonId, discussion.circleVisibility]);
}, [commonId, discussion?.circleVisibility]);

useEffect(() => {
if (chatChannel?.id) {
Expand Down Expand Up @@ -602,10 +604,11 @@ export default function ChatComponent({
users={users}
discussionId={discussionId}
feedItemId={feedItemId}
isLoading={isLoadingDiscussionMessages}
isLoading={!discussion || isLoadingDiscussionMessages}
onMessageDelete={handleMessageDelete}
directParent={directParent}
onUserClick={onUserClick}
onFeedItemClick={onFeedItemClick}
/>
</div>
{isAuthorized && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ interface ChatContentInterface {
onMessageDelete?: (messageId: string) => void;
directParent?: DirectParent | null;
onUserClick?: (userId: string) => void;
onFeedItemClick?: (feedItemId: string) => void;
}

const isToday = (someDate: Date) => {
Expand Down Expand Up @@ -89,6 +90,7 @@ const ChatContent: ForwardRefRenderFunction<
onMessageDelete,
directParent,
onUserClick,
onFeedItemClick,
},
chatContentRef,
) => {
Expand Down Expand Up @@ -266,6 +268,7 @@ const ChatContent: ForwardRefRenderFunction<
onMessageDelete={onMessageDelete}
directParent={directParent}
onUserClick={onUserClick}
onFeedItemClick={onFeedItemClick}
/>
);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/common/components/ChatComponent/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
export interface ChatItem {
feedItemId: string;
proposal?: Proposal;
discussion: Discussion;
discussion?: Discussion;
chatChannel?: ChatChannel;
circleVisibility: string[];
lastSeenItem?: CommonFeedObjectUserUnique["lastSeen"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ export const FeedTab: FC<FeedTabProps> = (props) => {
<p
className={classNames(styles.chatDiscussionTitle, {
[styles.chatDiscussionTitleRTL]: isRTL(
chatItem.discussion.title,
chatItem.discussion?.title,
),
})}
>
{chatItem.discussion.title}
{chatItem.discussion?.title}
</p>
<ChatComponent
governanceCircles={governance.circles}
Expand Down Expand Up @@ -155,7 +155,7 @@ export const FeedTab: FC<FeedTabProps> = (props) => {
}}
commonName={common.name}
commonImage={common.image}
title={chatItem?.discussion.title}
title={chatItem?.discussion?.title}
>
{chatItem && (
<ChatComponent
Expand Down Expand Up @@ -191,9 +191,9 @@ export const FeedTab: FC<FeedTabProps> = (props) => {
const contextValue = useMemo(
() => ({
setChatItem,
activeItemDiscussionId: chatItem?.discussion.id,
activeItemDiscussionId: chatItem?.discussion?.id,
}),
[setChatItem, chatItem?.discussion.id],
[setChatItem, chatItem?.discussion?.id],
);

return (
Expand Down
Loading
Loading