Skip to content

Commit 6e54820

Browse files
authored
Merge pull request #2699 from daostack/staging
Merge Staging to Production
2 parents 1ecbd61 + fa455b0 commit 6e54820

File tree

104 files changed

+1996
-539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1996
-539
lines changed

src/constants.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ $success-300: #6ee569;
166166
$c-input-100: #f9fafa;
167167
$c-light-gray: #f4f5f5;
168168
$c-light-gray-2: #f8f8f8;
169+
$c-light-gray-3: #f4f5f5;
169170
$c-sidebar-shadow: rgba(0, 26, 54, 0.08);
170171
$c-sidebar-user-menu-shadow: rgba(0, 0, 0, 0.15259);
171172
$c-common-card-shadow: rgba(0, 26, 54, 0.08);
@@ -175,6 +176,8 @@ $split-view-resizer-border-hover-color: rgba(0, 0, 0, 0.5);
175176
$editor-checkbox-inactive: #99999d;
176177
$editor-checkbox-active: #d84ca0;
177178
$chat-checkbox-inactive: #cecece;
179+
$link-my-reply-bg: #943367;
180+
$link-my-reply: #ffa2ea;
178181

179182
/* breakpoints */
180183
$small-laptop: 1366px;

src/pages/Auth/store/saga.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ const resetGlobalData = (fullReset: boolean) => {
301301
store.dispatch(inboxActions.resetInbox());
302302
store.dispatch(cacheActions.resetFeedStates());
303303
store.dispatch(cacheActions.resetDiscussionMessagesStates());
304+
store.dispatch(cacheActions.resetChatChannelMessagesStates());
304305
store.dispatch(commonActions.resetCommon());
305306
};
306307

src/pages/OldCommon/components/CommonDetailContainer/CommonWhitepaper/components/WhitepaperMembers/WhitepaperMembers.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useSelector } from "react-redux";
33
import classNames from "classnames";
44
import { selectGovernance } from "@/pages/OldCommon/store/selectors";
55
import { ProposalsTypes } from "@/shared/constants";
6-
import { AllowedActions, AllowedProposals, CircleType } from "@/shared/models";
6+
import { AllowedActions, AllowedProposals } from "@/shared/models";
77
import { getTextForProposalType } from "@/shared/utils";
88
import { generateCirclesBinaryNumber } from "../../utils";
99
import { getTextForAction, checkShouldRemoveAction } from "./helpers";
@@ -22,20 +22,17 @@ export default function WhitepaperMembers({ isSubCommon }: Props) {
2222

2323
const members = Object.values(governance?.circles || {})
2424
.slice(0, 5)
25-
.map((circle, index) => {
26-
if (circle?.type !== CircleType.Project)
27-
return (
28-
<li
29-
key={index}
30-
onClick={() => setSelectedMember({ ...circle, index })}
31-
className={classNames({
32-
active: selectedMember?.name === circle.name,
33-
})}
34-
>
35-
{circle.name}
36-
</li>
37-
);
38-
});
25+
.map((circle, index) => (
26+
<li
27+
key={index}
28+
onClick={() => setSelectedMember({ ...circle, index })}
29+
className={classNames({
30+
active: selectedMember?.name === circle.name,
31+
})}
32+
>
33+
{circle.name}
34+
</li>
35+
));
3936

4037
const renderContent = () => {
4138
const circle = Object.values(governance?.circles || {}).filter(

src/pages/OldCommon/components/CommonDetailContainer/MembersComponent/CommonMemberComponent.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
getCirclesWithHighestTier,
1818
getFilteredByIdCircles,
1919
getUserName,
20-
removeProjectCircles,
2120
} from "@/shared/utils";
2221
import { selectRecentAssignedCircle } from "@/store/states";
2322
import { UserAvatar, UserInfoPopup } from "../../../../../shared/components";
@@ -92,10 +91,8 @@ const CommonMember: FC<CommonMemberProps> = ({
9291
}
9392
});
9493

95-
const notMemberCircles = removeProjectCircles(
96-
governanceCircles.filter(
97-
({ id }) => !memberCircles.map((circle) => circle.id).includes(id),
98-
),
94+
const notMemberCircles = governanceCircles.filter(
95+
({ id }) => !memberCircles.map((circle) => circle.id).includes(id),
9996
);
10097

10198
const circlesString = getCirclesWithHighestTier(memberCircles)

src/pages/OldCommon/hooks/useCommonMember.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ export const useCommonMember = (options: Options = {}): Return => {
7272
const dispatch = useDispatch();
7373
const currentLoadingIdRef = useRef("");
7474
const isMounted = useIsMounted();
75-
const [state, setState] = useState<State>({
76-
loading: false,
77-
fetched: false,
78-
data: null,
79-
});
8075
const [missingCirclesError, setMissingCirclesError] = useState(false);
8176
const user = useSelector(selectUser());
8277
const userId = options.userId || user?.uid;
@@ -94,6 +89,7 @@ export const useCommonMember = (options: Options = {}): Return => {
9489
identificationInfo || { userId: "", commonId: "" },
9590
),
9691
) || DEFAULT_STATE;
92+
const [state, setState] = useState<State>(commonMemberState);
9793
const commonMemberId = state.data?.id;
9894

9995
const fetchCommonMember = useCallback(
@@ -264,24 +260,31 @@ export const useCommonMember = (options: Options = {}): Return => {
264260
CommonService.subscribeToCommonMemberByCommonIdAndUserId(
265261
commonId,
266262
userId,
267-
(commonMember, { isAdded, isRemoved }) => {
263+
(subscriptionData) => {
268264
try {
269265
let data: State["data"] = null;
270266

271-
if (isAdded) {
272-
CommonEventEmitter.emit(CommonEvent.ProjectUpdated, {
273-
commonId,
274-
hasMembership: true,
275-
});
276-
}
277-
if (!isRemoved) {
278-
data = {
279-
...commonMember,
280-
...generateCirclesDataForCommonMember(
281-
governanceCircles,
282-
commonMember.circleIds,
283-
),
284-
};
267+
if (subscriptionData) {
268+
const {
269+
commonMember,
270+
statuses: { isAdded, isRemoved },
271+
} = subscriptionData;
272+
273+
if (isAdded) {
274+
CommonEventEmitter.emit(CommonEvent.ProjectUpdated, {
275+
commonId,
276+
hasMembership: true,
277+
});
278+
}
279+
if (!isRemoved) {
280+
data = {
281+
...commonMember,
282+
...generateCirclesDataForCommonMember(
283+
governanceCircles,
284+
commonMember.circleIds,
285+
),
286+
};
287+
}
285288
}
286289

287290
const finalState = {

src/pages/common/components/ChatComponent/ChatComponent.tsx

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,24 @@ import { debounce, delay, omit } from "lodash";
1515
import { v4 as uuidv4 } from "uuid";
1616
import { selectUser } from "@/pages/Auth/store/selectors";
1717
import { ChatService, DiscussionMessageService, FileService } from "@/services";
18+
import { Separator } from "@/shared/components";
1819
import {
1920
ChatType,
2021
DiscussionMessageOwnerType,
2122
GovernanceActions,
2223
LastSeenEntity,
24+
QueryParamKey,
2325
} from "@/shared/constants";
2426
import { FILES_ACCEPTED_EXTENSIONS } from "@/shared/constants";
2527
import { HotKeys } from "@/shared/constants/keyboardKeys";
2628
import { ChatMessageToUserDiscussionMessageConverter } from "@/shared/converters";
27-
import { useZoomDisabling, useImageSizeCheck } from "@/shared/hooks";
29+
import {
30+
useZoomDisabling,
31+
useImageSizeCheck,
32+
useQueryParams,
33+
} from "@/shared/hooks";
2834
import { ArrowInCircleIcon, PlusIcon, SendIcon } from "@/shared/icons";
35+
import { LinkPreviewData } from "@/shared/interfaces";
2936
import { CreateDiscussionMessageDto } from "@/shared/interfaces/api/discussionMessages";
3037
import {
3138
ChatChannel,
@@ -69,9 +76,12 @@ import { ChatContentContext, ChatContentData } from "../CommonContent/context";
6976
import {
7077
ChatContent,
7178
ChatContentRef,
79+
MessageLinkPreview,
7280
MessageReply,
7381
ChatFilePreview,
82+
MessageInfoWithDateList,
7483
} from "./components";
84+
import { checkIsLastSeenInPreviousDay } from "./components/ChatContent/utils";
7585
import { useChatChannelChatAdapter, useDiscussionChatAdapter } from "./hooks";
7686
import { getLastNonUserMessage } from "./utils";
7787
import styles from "./ChatComponent.module.scss";
@@ -150,6 +160,9 @@ export default function ChatComponent({
150160
onInternalLinkClick,
151161
}: ChatComponentInterface) {
152162
const dispatch = useDispatch();
163+
const queryParams = useQueryParams();
164+
const shouldDisplayMessagesOnlyWithUncheckedItems =
165+
queryParams[QueryParamKey.Unchecked] === "true";
153166
const { checkImageSize } = useImageSizeCheck();
154167
useZoomDisabling();
155168
const editorRef = useRef<HTMLElement>(null);
@@ -197,7 +210,10 @@ export default function ChatComponent({
197210
markChatChannelAsSeen,
198211
chatUsers,
199212
fetchChatUsers,
200-
} = useChatChannelChatAdapter({ participants: chatChannel?.participants });
213+
} = useChatChannelChatAdapter({
214+
chatChannelId: chatChannel?.id || "",
215+
participants: chatChannel?.participants,
216+
});
201217
const users = chatChannel ? chatUsers : discussionUsers;
202218
const discussionMessages = chatChannel
203219
? chatMessagesData.data
@@ -207,13 +223,18 @@ export default function ChatComponent({
207223
const areInitialMessagesLoading = isChatChannel
208224
? chatMessagesData.loading
209225
: discussionMessagesData.loading;
210-
const areMessagesLoading = discussionMessagesData.isBatchLoading;
226+
const areMessagesLoading = chatChannel
227+
? chatMessagesData.isBatchLoading
228+
: discussionMessagesData.isBatchLoading;
211229
const currentFilesPreview = useSelector(selectFilesPreview());
212230
const chatContentRef = useRef<ChatContentRef>(null);
213231
const chatWrapperId = useMemo(() => `chat-wrapper-${uuidv4()}`, []);
214232
const chatInputWrapperRef = useRef<HTMLDivElement>(null);
215233
const chatContainerRef = useRef<HTMLDivElement>(null);
216234
const [isScrolling, setIsScrolling] = useState(false);
235+
const [linkPreviewData, setLinkPreviewData] = useState<
236+
LinkPreviewData | null | undefined
237+
>();
217238
const chatContentContextValue: ChatContentData = useMemo(
218239
() => ({
219240
isScrolling,
@@ -279,7 +300,43 @@ export default function ChatComponent({
279300
),
280301
[discussionMessages],
281302
);
282-
const dateList = useMemo(() => Object.keys(messages), [messages]);
303+
304+
const dateList: MessageInfoWithDateList = useMemo(() => {
305+
const messagesDates = Object.keys(messages);
306+
const messagesWithInfo = messagesDates.map((day, dayIndex) => {
307+
const date = new Date(Number(day));
308+
const currentMessages = shouldDisplayMessagesOnlyWithUncheckedItems
309+
? messages[Number(day)].filter((message) => message.hasUncheckedItems)
310+
: messages[Number(day)];
311+
const previousDayMessages =
312+
messages[Number(messagesDates[dayIndex + 1])] || [];
313+
const isLastSeenInPreviousDay = checkIsLastSeenInPreviousDay(
314+
previousDayMessages,
315+
lastSeenItem?.id,
316+
);
317+
const isMyMessageFirst =
318+
checkIsUserDiscussionMessage(currentMessages[0]) &&
319+
currentMessages[0].ownerId === userId;
320+
const newSeparatorEl = (
321+
<li>
322+
<Separator>New</Separator>
323+
</li>
324+
);
325+
326+
return {
327+
day,
328+
date,
329+
currentMessages,
330+
isLastSeenInPreviousDay,
331+
isMyMessageFirst,
332+
newSeparatorEl,
333+
};
334+
});
335+
336+
return messagesWithInfo;
337+
}, [messages]);
338+
339+
// const dateListWith
283340

284341
const [newMessages, setMessages] = useState<
285342
CreateDiscussionMessageDtoWithFilesPreview[]
@@ -338,6 +395,7 @@ export default function ChatComponent({
338395
hasUncheckedItems: checkUncheckedItemsInTextEditorValue(
339396
parseStringToTextEditorValue(payload.text),
340397
),
398+
linkPreviews: payload.linkPreviews,
341399
});
342400
chatMessagesData.updateChatMessage(response);
343401

@@ -442,6 +500,12 @@ export default function ChatComponent({
442500
tags: mentionTags,
443501
mentions: mentionTags.map((tag) => tag.value),
444502
hasUncheckedItems: checkUncheckedItemsInTextEditorValue(message),
503+
linkPreviews:
504+
typeof linkPreviewData === "undefined"
505+
? undefined
506+
: linkPreviewData
507+
? [linkPreviewData]
508+
: [],
445509
};
446510

447511
const filePreviewPayload: CreateDiscussionMessageDtoWithFilesPreview[] =
@@ -512,6 +576,7 @@ export default function ChatComponent({
512576
),
513577
tags: mentionTags,
514578
hasUncheckedItems: checkUncheckedItemsInTextEditorValue(message),
579+
linkPreviews: payload.linkPreviews,
515580
});
516581
}
517582

@@ -557,6 +622,7 @@ export default function ChatComponent({
557622
discussionId,
558623
discussionMessages,
559624
isChatChannel,
625+
linkPreviewData,
560626
],
561627
);
562628

@@ -847,6 +913,10 @@ export default function ChatComponent({
847913
</div>
848914
)}
849915
<MessageReply users={users} />
916+
<MessageLinkPreview
917+
message={message}
918+
onLinkPreviewDataChange={setLinkPreviewData}
919+
/>
850920
<ChatFilePreview />
851921
<div
852922
ref={chatInputWrapperRef}

0 commit comments

Comments
 (0)