Skip to content

Commit

Permalink
Merge pull request #1912 from daostack/feature/CW-1907-auto-info-card…
Browse files Browse the repository at this point in the history
…-opening

Logic for auto opening info card #1907
  • Loading branch information
andreymikhadyuk authored Aug 1, 2023
2 parents 7ea113b + bb72145 commit 21aec0c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/pages/common/components/ChatComponent/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface ChatItem {
circleVisibility: string[];
lastSeenItem?: CommonFeedObjectUserUnique["lastSeen"];
seenOnce?: boolean;
isLiveVoting?: boolean;
}

export interface ChatContextValue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
CommonFeed,
Governance,
PredefinedTypes,
ProposalState,
ResolutionType,
} from "@/shared/models";
import { TextEditorValue } from "@/shared/ui-kit";
Expand Down Expand Up @@ -228,6 +229,7 @@ const ProposalFeedCard: React.FC<ProposalFeedCardProps> = (props) => {
circleVisibility: item.circleVisibility,
lastSeenItem: feedItemUserMetadata?.lastSeen,
seenOnce: feedItemUserMetadata?.seenOnce,
isLiveVoting: proposal.state === ProposalState.VOTING,
});
}
}, [
Expand Down
3 changes: 3 additions & 0 deletions src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
userCircleIds={userCircleIds}
isShowFeedItemDetailsModal={isShowFeedItemDetailsModal}
sizeKey={sizeKey}
isMainModalOpen={Boolean(chatItem)}
seenOnce={chatItem?.seenOnce}
isLiveVoting={chatItem?.isLiveVoting}
/>
)}
</MobileChat>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useState } from "react";
import React, { FC, useEffect, useState } from "react";
import { FeedItem } from "@/pages/common";
import { useChatContext } from "@/pages/common/components/ChatComponent";
import { Modal } from "@/shared/components";
Expand All @@ -21,6 +21,9 @@ interface FeedItemPreviewModalProps {
governanceCircles?: Circles;
isShowFeedItemDetailsModal?: boolean;
sizeKey?: string;
isMainModalOpen: boolean;
seenOnce?: boolean;
isLiveVoting?: boolean;
}

const FeedItemPreviewModal: FC<FeedItemPreviewModalProps> = (props) => {
Expand All @@ -34,6 +37,9 @@ const FeedItemPreviewModal: FC<FeedItemPreviewModalProps> = (props) => {
governanceCircles,
isShowFeedItemDetailsModal,
sizeKey,
isMainModalOpen,
seenOnce,
isLiveVoting,
} = props;
const isTabletView = useIsTabletView();
const { setIsShowFeedItemDetailsModal } = useChatContext();
Expand All @@ -48,6 +54,12 @@ const FeedItemPreviewModal: FC<FeedItemPreviewModalProps> = (props) => {
setTitle(data.title);
};

useEffect(() => {
if (isMainModalOpen && (!seenOnce || isLiveVoting)) {
setIsShowFeedItemDetailsModal?.(true);
}
}, [isMainModalOpen]);

return (
<Modal
className={styles.modal}
Expand Down

0 comments on commit 21aec0c

Please sign in to comment.