Skip to content

Commit

Permalink
CW-Optimistic-stream Remove unnecessary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MeyerPV committed Sep 1, 2024
1 parent 45a9a65 commit a6eaa74
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 23 deletions.
2 changes: 2 additions & 0 deletions src/pages/common/components/ChatComponent/ChatComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ export default function ChatComponent({
const timeoutId = useRef<ReturnType<typeof setTimeout> | null>();

const optimisticFeedItems = useSelector(selectOptimisticFeedItems);

console.log("--optimisticFeedItems", optimisticFeedItems);
const optimisticDiscussionMessages = useSelector(
selectOptimisticDiscussionMessages,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import React, { FC, ReactNode, useCallback, useMemo } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Timestamp as FirestoreTimestamp } from "firebase/firestore";
import { v4 as uuidv4 } from "uuid";
import { selectUser } from "@/pages/Auth/store/selectors";
import {
DiscussionMessageOwnerType,
PROPOSAL_TYPE_SELECT_OPTIONS,
ProposalsTypes,
} from "@/shared/constants";
import { NewProposalCreationFormValues } from "@/shared/interfaces";
import {
CirclesPermissions,
Common,
CommonFeedType,
CommonMember,
Governance,
OptimisticFeedItemState,
} from "@/shared/models";
import { parseStringToTextEditorValue } from "@/shared/ui-kit/TextEditor";
import { getUserName } from "@/shared/utils";
import {
selectIsProposalCreationLoading,
selectProposalCreationData,
Expand Down Expand Up @@ -85,6 +90,53 @@ const NewProposalCreation: FC<NewProposalCreationProps> = (props) => {

const proposalId = uuidv4();
const discussionId = uuidv4();
const currentDate = FirestoreTimestamp.now();

const optimisticFeedItemId = uuidv4();
dispatch(
commonActions.setOptimisticFeedItem({
id: optimisticFeedItemId,
createdAt: currentDate,
updatedAt: currentDate,
isDeleted: false,
userId,
commonId: common.id,
data: {
type: CommonFeedType.OptimisticDiscussion,
id: discussionId,
discussionId: null,
lastMessage: {
userName: getUserName(user),
ownerId: userId,
content: JSON.stringify(values.content),
ownerType: DiscussionMessageOwnerType.User,
},
hasFiles: false,
hasImages: false,
},
optimisticData: {
id: discussionId,
title: values.title,
message: JSON.stringify(values.content),
ownerId: userId,
commonId: common.id,
lastMessage: currentDate,
updatedAt: currentDate,
createdAt: currentDate,
messageCount: 0,
followers: [],
files: [],
images: [],
discussionMessages: [],
isDeleted: false,
circleVisibility: userCircleIds,
circleVisibilityByCommon: null,
linkedCommonIds: [],
state: OptimisticFeedItemState.loading,
},
circleVisibility: userCircleIds,
}),
);
switch (values.proposalType.value) {
case ProposalsTypes.FUNDS_ALLOCATION: {
const fundingProposalPayload = getFundingProposalPayload(
Expand All @@ -106,11 +158,25 @@ const NewProposalCreation: FC<NewProposalCreationProps> = (props) => {
break;
}
case ProposalsTypes.SURVEY: {
dispatch(
commonActions.createSurveyProposal.request({
payload: getSurveyProposalPayload(values, commonId, proposalId, discussionId),
}),
console.log(
"----getSurveyProposalPayload",
getSurveyProposalPayload(
values,
commonId,
proposalId,
discussionId,
),
);
// dispatch(
// commonActions.createSurveyProposal.request({
// payload: getSurveyProposalPayload(
// values,
// commonId,
// proposalId,
// discussionId,
// ),
// }),
// );
break;
}
}
Expand Down
37 changes: 18 additions & 19 deletions src/pages/common/components/FeedItems/FeedItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,24 @@ const FeedItems: FC<FeedItemsProps> = (props) => {
(pinnedItem) => pinnedItem.feedObjectId === item.feedItem.id,
);

return <></>;
// return (
// <FeedItem
// key={item.feedItem.id}
// commonId={common.id}
// commonName={common.name}
// commonImage={common.image}
// commonNotion={common.notion}
// pinnedFeedItems={common.pinnedFeedItems}
// isPinned={isPinned}
// isProject={checkIsProject(common)}
// item={item.feedItem}
// governanceCircles={governance.circles}
// isMobileVersion={isTabletView}
// userCircleIds={userCircleIds}
// isPreviewMode
// directParent={common.directParent}
// />
// );
return (
<FeedItem
key={item.feedItem.id}
commonId={common.id}
commonName={common.name}
commonImage={common.image}
commonNotion={common.notion}
pinnedFeedItems={common.pinnedFeedItems}
isPinned={isPinned}
isProject={checkIsProject(common)}
item={item.feedItem}
governanceCircles={governance.circles}
isMobileVersion={isTabletView}
userCircleIds={userCircleIds}
isPreviewMode
directParent={common.directParent}
/>
);
})}
</InfiniteScroll>
</FeedItemContext.Provider>
Expand Down

0 comments on commit a6eaa74

Please sign in to comment.