Skip to content

Commit fd6b3ba

Browse files
authored
Merge pull request #2710 from daostack/dev
Sprint 34
2 parents fa455b0 + 703fee7 commit fd6b3ba

File tree

27 files changed

+796
-546
lines changed

27 files changed

+796
-546
lines changed

craco.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
const CracoAlias = require("craco-alias");
22

33
module.exports = {
4+
webpack: {
5+
configure: (webpackConfig, { env, paths }) => {
6+
const reactAppEnv = process.env.REACT_APP_ENV;
7+
if (reactAppEnv === "dev" || reactAppEnv === "stage") {
8+
webpackConfig.optimization.minimize = false;
9+
webpackConfig.devtool = "source-map";
10+
} else {
11+
webpackConfig.devtool = false;
12+
}
13+
return webpackConfig;
14+
},
15+
},
416
style: {
517
css: {
618
loaderOptions: () => ({

public/manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"short_name": "React App",
3-
"name": "Create React App Sample",
2+
"short_name": "Common.io",
3+
"name": "Common.io",
44
"icons": [
55
{
66
"src": "favicon.ico",
@@ -38,7 +38,7 @@
3838
"sizes": "512x512"
3939
}
4040
],
41-
"start_url": ".",
41+
"start_url": "./inbox",
4242
"display": "standalone",
4343
"theme_color": "#000000",
4444
"background_color": "#ffffff"

src/pages/OldCommon/hooks/useCommonMembers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useEffect, useRef, useState } from "react";
1+
import { useCallback, useRef, useState } from "react";
22
import { useDispatch, useSelector } from "react-redux";
33
import { CommonService, Logger, UserService } from "@/services";
44
import { store } from "@/shared/appConfig";
@@ -9,6 +9,7 @@ import {
99
selectCommonMembersStateByCommonId,
1010
selectUserStates,
1111
} from "@/store/states";
12+
import { useDeepCompareEffect } from "react-use";
1213

1314
interface Options {
1415
commonId?: string;
@@ -93,7 +94,7 @@ export const useCommonMembers = ({ commonId }: Options): Return => {
9394
[dispatch, commonId],
9495
);
9596

96-
useEffect(() => {
97+
useDeepCompareEffect(() => {
9798
const commonMembers = commonMembersState.data;
9899

99100
if (!commonMembers) {

src/pages/common/components/ChatComponent/ChatComponent.module.scss

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -50,59 +50,6 @@
5050
align-items: flex-end;
5151
}
5252

53-
.messageInput {
54-
width: 100%;
55-
min-height: 2.625rem;
56-
line-height: 1.5rem;
57-
border-radius: 1.25rem;
58-
background-color: var(--secondary-background);
59-
border: 0.0625rem solid var(--gentle-stroke);
60-
outline: none;
61-
resize: none;
62-
font-size: 0.875rem;
63-
color: var(--primary-text);
64-
box-sizing: border-box;
65-
text-align: left;
66-
display: flex;
67-
flex-direction: column;
68-
justify-content: center;
69-
word-break: break-word;
70-
padding: 0.125rem 2.5rem 0.125rem 0.75rem;
71-
margin: 0.3rem 0;
72-
overflow-x: hidden;
73-
min-height: 2.625rem !important;
74-
}
75-
76-
.messageInputRtl {
77-
padding: 0.125rem 2.5rem 0.125rem 0.75rem;
78-
}
79-
80-
.messageInputEmpty {
81-
padding-left: 0.75rem;
82-
overflow-x: hidden;
83-
}
84-
85-
.addFilesIcon {
86-
margin-bottom: 0.8rem;
87-
margin-right: 0.5rem;
88-
height: 1.5rem;
89-
color: var(--primary-text);
90-
}
91-
92-
.sendIcon {
93-
display: flex;
94-
justify-content: center;
95-
align-items: center;
96-
margin-bottom: 0.8rem;
97-
border: none;
98-
outline: none;
99-
background: transparent;
100-
101-
&:disabled {
102-
cursor: not-allowed;
103-
opacity: 0.5;
104-
}
105-
}
10653
$phone-breakpoint: 415px;
10754

10855
.container {

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

Lines changed: 23 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ import {
2323
LastSeenEntity,
2424
QueryParamKey,
2525
} from "@/shared/constants";
26-
import { FILES_ACCEPTED_EXTENSIONS } from "@/shared/constants";
2726
import { HotKeys } from "@/shared/constants/keyboardKeys";
2827
import { ChatMessageToUserDiscussionMessageConverter } from "@/shared/converters";
2928
import {
3029
useZoomDisabling,
3130
useImageSizeCheck,
3231
useQueryParams,
3332
} from "@/shared/hooks";
34-
import { ArrowInCircleIcon, PlusIcon, SendIcon } from "@/shared/icons";
33+
import { ArrowInCircleIcon } from "@/shared/icons";
3534
import { LinkPreviewData } from "@/shared/interfaces";
3635
import { CreateDiscussionMessageDto } from "@/shared/interfaces/api/discussionMessages";
3736
import {
@@ -47,24 +46,16 @@ import {
4746
UserDiscussionMessage,
4847
} from "@/shared/models";
4948
import {
50-
BaseTextEditor,
5149
TextEditorValue,
5250
getMentionTags,
5351
parseStringToTextEditorValue,
54-
ButtonIcon,
5552
checkIsTextEditorValueEmpty,
56-
TextEditorSize,
5753
removeTextEditorEmptyEndLinesValues,
5854
countTextEditorEmojiElements,
5955
} from "@/shared/ui-kit";
6056
import { checkUncheckedItemsInTextEditorValue } from "@/shared/ui-kit/TextEditor/utils";
6157
import { InternalLinkData, notEmpty } from "@/shared/utils";
62-
import {
63-
emptyFunction,
64-
getUserName,
65-
hasPermission,
66-
isMobile,
67-
} from "@/shared/utils";
58+
import { getUserName, hasPermission, isMobile } from "@/shared/utils";
6859
import {
6960
cacheActions,
7061
chatActions,
@@ -80,6 +71,7 @@ import {
8071
MessageReply,
8172
ChatFilePreview,
8273
MessageInfoWithDateList,
74+
ChatInput,
8375
} from "./components";
8476
import { checkIsLastSeenInPreviousDay } from "./components/ChatContent/utils";
8577
import { useChatChannelChatAdapter, useDiscussionChatAdapter } from "./hooks";
@@ -336,8 +328,6 @@ export default function ChatComponent({
336328
return messagesWithInfo;
337329
}, [messages]);
338330

339-
// const dateListWith
340-
341331
const [newMessages, setMessages] = useState<
342332
CreateDiscussionMessageDtoWithFilesPreview[]
343333
>([]);
@@ -761,73 +751,6 @@ export default function ChatComponent({
761751
};
762752
}, []);
763753

764-
const renderChatInput = (): ReactNode => {
765-
if (shouldHideChatInput) {
766-
return null;
767-
}
768-
if (!isChatChannel) {
769-
const chatInputEl = renderChatInputOuter?.();
770-
771-
if (chatInputEl || chatInputEl === null) {
772-
return chatInputEl;
773-
}
774-
}
775-
if (!isAuthorized) {
776-
return null;
777-
}
778-
779-
return (
780-
<>
781-
<ButtonIcon
782-
className={styles.addFilesIcon}
783-
onClick={() => {
784-
document.getElementById("file")?.click();
785-
}}
786-
>
787-
<PlusIcon />
788-
</ButtonIcon>
789-
<input
790-
id="file"
791-
type="file"
792-
onChange={uploadFiles}
793-
style={{ display: "none" }}
794-
multiple
795-
accept={FILES_ACCEPTED_EXTENSIONS}
796-
/>
797-
<BaseTextEditor
798-
inputContainerRef={inputContainerRef}
799-
size={TextEditorSize.Auto}
800-
editorRef={editorRef}
801-
className={classNames(styles.messageInput, {
802-
[styles.messageInputEmpty]: checkIsTextEditorValueEmpty(message),
803-
})}
804-
classNameRtl={styles.messageInputRtl}
805-
elementStyles={{
806-
emoji: classNames({
807-
[styles.singleEmojiText]: emojiCount.isSingleEmoji,
808-
[styles.multipleEmojiText]: emojiCount.isMultipleEmoji,
809-
}),
810-
}}
811-
value={message}
812-
onChange={setMessage}
813-
placeholder="Message"
814-
onKeyDown={onEnterKeyDown}
815-
users={users}
816-
shouldReinitializeEditor={shouldReinitializeEditor}
817-
onClearFinished={onClearFinished}
818-
scrollSelectionIntoView={emptyFunction}
819-
/>
820-
<button
821-
className={styles.sendIcon}
822-
onClick={sendChatMessage}
823-
disabled={!canSendMessage}
824-
>
825-
<SendIcon />
826-
</button>
827-
</>
828-
);
829-
};
830-
831754
const { y } = useScroll(chatContainerRef);
832755
const isScrolledToTop = Boolean(chatContainerRef.current && Math.abs(y) > 20);
833756

@@ -924,7 +847,26 @@ export default function ChatComponent({
924847
[styles.chatInputWrapperMultiLine]: isMultiLineInput,
925848
})}
926849
>
927-
{renderChatInput()}
850+
<ChatInput
851+
onClearFinished={onClearFinished}
852+
shouldReinitializeEditor={shouldReinitializeEditor}
853+
users={users}
854+
onEnterKeyDown={onEnterKeyDown}
855+
emojiCount={emojiCount}
856+
setMessage={setMessage}
857+
message={message}
858+
uploadFiles={uploadFiles}
859+
isAuthorized={isAuthorized}
860+
renderChatInputOuter={
861+
renderChatInputOuter as () => React.ReactElement
862+
}
863+
isChatChannel={isChatChannel}
864+
shouldHideChatInput={shouldHideChatInput}
865+
sendChatMessage={sendChatMessage}
866+
canSendMessage={Boolean(canSendMessage)}
867+
inputContainerRef={inputContainerRef}
868+
editorRef={editorRef}
869+
/>
928870
</div>
929871
</div>
930872
);
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
@import "../../../../../../constants.scss";
2+
@import "../../../../../../styles/sizes";
3+
4+
.messageInput {
5+
width: 100%;
6+
min-height: 2.625rem;
7+
line-height: 1.5rem;
8+
border-radius: 1.25rem;
9+
background-color: var(--secondary-background);
10+
border: 0.0625rem solid var(--gentle-stroke);
11+
outline: none;
12+
resize: none;
13+
font-size: 0.875rem;
14+
color: var(--primary-text);
15+
box-sizing: border-box;
16+
text-align: left;
17+
display: flex;
18+
flex-direction: column;
19+
justify-content: center;
20+
word-break: break-word;
21+
padding: 0.125rem 2.5rem 0.125rem 0.75rem;
22+
margin: 0.3rem 0;
23+
overflow-x: hidden;
24+
min-height: 2.625rem !important;
25+
}
26+
27+
.messageInputRtl {
28+
padding: 0.125rem 2.5rem 0.125rem 0.75rem;
29+
}
30+
31+
.messageInputEmpty {
32+
padding-left: 0.75rem;
33+
overflow-x: hidden;
34+
}
35+
36+
.addFilesIcon {
37+
margin-bottom: 0.8rem;
38+
margin-right: 0.5rem;
39+
height: 1.5rem;
40+
color: var(--primary-text);
41+
}
42+
43+
.sendIcon {
44+
display: flex;
45+
justify-content: center;
46+
align-items: center;
47+
margin-bottom: 0.8rem;
48+
border: none;
49+
outline: none;
50+
background: transparent;
51+
52+
&:disabled {
53+
cursor: not-allowed;
54+
opacity: 0.5;
55+
}
56+
}
57+
$phone-breakpoint: 415px;
58+
59+
.singleEmojiText {
60+
font-size: $xlarge;
61+
line-height: 2.8125rem;
62+
}
63+
64+
.multipleEmojiText {
65+
font-size: $large;
66+
line-height: 2.125rem;
67+
}
68+
69+
.singleEmojiText {
70+
font-size: $xlarge;
71+
}
72+
73+
.multipleEmojiText {
74+
font-size: $large;
75+
}

0 commit comments

Comments
 (0)