@messenger-box/platform-browser 0.0.1-alpha.42 → 0.0.1-alpha.420
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +540 -27
- package/jest.config.js +23 -7
- package/lib/components/InboxMessage/InboxDetails/index.d.ts +2 -0
- package/lib/components/InboxMessage/InboxDetails/style.d.ts +1 -0
- package/lib/components/InboxMessage/InboxSidebar/index.d.ts +11 -0
- package/lib/components/InboxMessage/InboxSidebar/styles.d.ts +1 -0
- package/lib/components/InboxMessage/Messages/index.d.ts +2 -0
- package/lib/components/InboxMessage/Messages/styles.d.ts +80 -0
- package/lib/components/InboxMessage/MessagesList/index.d.ts +2 -0
- package/lib/components/InboxMessage/Popover/index.d.ts +2 -0
- package/lib/components/InboxMessage/Popover/style.d.ts +27 -0
- package/lib/components/InboxMessage/UserModalContent/index.d.ts +2 -0
- package/lib/components/InboxMessage/UserModalContent/style.d.ts +1 -0
- package/lib/components/InboxMessage/index.d.ts +2 -0
- package/lib/components/InboxMessage/mock.d.ts +19 -0
- package/lib/components/InboxMessage/style.d.ts +1 -0
- package/lib/components/channel_view/DirectChannelView.d.ts +3 -0
- package/lib/components/channel_view/PublicChannelView.d.ts +3 -0
- package/lib/components/dashboard/menu_header.d.ts +5 -0
- package/lib/components/dashboard/modals/direct_modal.d.ts +9 -0
- package/lib/components/dashboard/modals.d.ts +8 -0
- package/lib/components/messenger/index.d.ts +6 -1
- package/lib/components/messenger/messagesList/index.d.ts +6 -4
- package/lib/components/messenger/messagesList/style.d.ts +1 -221
- package/lib/components/messenger/more_action/index.d.ts +11 -0
- package/lib/components/messenger/more_action/style.d.ts +1 -0
- package/lib/components/overlay_trigger.d.ts +3 -3
- package/lib/components/post/channel_intro_message/channel_intro_message.d.ts +2 -1
- package/lib/components/post/channel_layout/channel_identifier_router/channel_identifier_router.d.ts +2 -1
- package/lib/components/post/channel_view/channel_view.d.ts +2 -1
- package/lib/components/post/create_post/create_post.d.ts +2 -1
- package/lib/components/post/failed_post_options/failed_post_options.d.ts +2 -1
- package/lib/components/post/index.d.ts +5 -1
- package/lib/components/post/markdown/markdown.d.ts +2 -1
- package/lib/components/post/post/post.d.ts +2 -1
- package/lib/components/post/post_aria_label_div.d.ts +3 -2
- package/lib/components/post/post_body/post_body.d.ts +2 -1
- package/lib/components/post/post_header/post_header.d.ts +2 -1
- package/lib/components/post/post_header/post_header_custom_status.d.ts +2 -1
- package/lib/components/post/post_header/style.d.ts +1 -40
- package/lib/components/post/post_info/post_info.d.ts +2 -1
- package/lib/components/post/post_list/index.d.ts +2 -1
- package/lib/components/post/post_list/post_list.d.ts +2 -1
- package/lib/components/post/post_list_row/post_list_row.d.ts +2 -1
- package/lib/components/post/post_list_virtualized/latest_post_reader.d.ts +2 -1
- package/lib/components/post/post_list_virtualized/post_list_virtualized.d.ts +2 -1
- package/lib/components/post/post_markdown/post_markdown.d.ts +2 -1
- package/lib/components/post/post_message_view/post_message_view.d.ts +2 -1
- package/lib/components/post/post_pre_header/post_pre_header.d.ts +3 -2
- package/lib/components/post/post_profile_picture/post_profile_picture.d.ts +2 -1
- package/lib/components/post/post_view.d.ts +2 -1
- package/lib/components/post/profile_picture/profile_picture.d.ts +2 -1
- package/lib/components/post/show_more/show_more.d.ts +2 -1
- package/lib/components/post/style.d.ts +1 -93
- package/lib/components/post/threading/channel_threads/thread_footer/thread_footer.d.ts +2 -1
- package/lib/components/post/threading/common/button/button.d.ts +3 -3
- package/lib/components/post/threading/common/follow_button/follow_button.d.ts +2 -2
- package/lib/components/post/tutorial/tutorial_tip/tutorial_tip.d.ts +3 -3
- package/lib/components/post/user_profile/user_profile.d.ts +1 -1
- package/lib/components/status_icon.d.ts +2 -1
- package/lib/components/status_icon_new.d.ts +2 -2
- package/lib/compute.d.ts +8 -2
- package/lib/containers/Inbox.d.ts +3 -0
- package/lib/containers/Messenger.d.ts +5 -1
- package/lib/index.js +3864 -581
- package/lib/index.js.map +1 -1
- package/lib/packages/types/emojis.d.ts +5 -5
- package/lib/packages/types/files.d.ts +5 -5
- package/lib/packages/types/posts.d.ts +13 -13
- package/lib/packages/types/reactions.d.ts +1 -1
- package/lib/packages/types/utilities.d.ts +13 -13
- package/lib/style.d.ts +1 -37
- package/lib/utils/index.d.ts +2 -0
- package/lib/widgets/badges/badge.d.ts +3 -3
- package/lib/widgets/badges/bot_badge.d.ts +1 -1
- package/lib/widgets/badges/guest_badge.d.ts +1 -1
- package/lib/widgets/badges/style.d.ts +1 -23
- package/lib/widgets/icons/emoji_icon.d.ts +1 -1
- package/lib/widgets/icons/flag_icon_filled.d.ts +1 -1
- package/lib/widgets/icons/mattermost_logo.d.ts +1 -1
- package/lib/widgets/icons/status_away_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_away_icon.d.ts +1 -1
- package/lib/widgets/icons/status_dnd_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_dnd_icon.d.ts +1 -1
- package/lib/widgets/icons/status_offline_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_offline_icon.d.ts +1 -1
- package/lib/widgets/icons/status_online_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_online_icon.d.ts +1 -1
- package/lib/widgets/overlay_trigger.d.ts +3 -3
- package/lib/widgets/shared_user_indicator.d.ts +1 -1
- package/lib/widgets/simple_tooltip/simple_tooltip.d.ts +3 -3
- package/lib/widgets/users/avatar/avatar.d.ts +4 -4
- package/lib/widgets/users/avatar/style.d.ts +1 -75
- package/lib/widgets/users/avatars/avatars.d.ts +2 -2
- package/package.json +61 -67
- package/src/components/InboxMessage/InboxDetails/index.tsx +23 -0
- package/src/components/InboxMessage/InboxDetails/style.ts +27 -0
- package/src/components/InboxMessage/InboxSidebar/index.tsx +86 -0
- package/src/components/InboxMessage/InboxSidebar/styles.ts +57 -0
- package/src/components/InboxMessage/Messages/index.tsx +159 -0
- package/src/components/InboxMessage/Messages/styles.ts +85 -0
- package/src/components/InboxMessage/MessagesList/index.tsx +93 -0
- package/src/components/InboxMessage/Popover/index.tsx +57 -0
- package/src/components/InboxMessage/Popover/style.ts +27 -0
- package/src/components/InboxMessage/UserModalContent/index.tsx +60 -0
- package/src/components/InboxMessage/UserModalContent/style.ts +98 -0
- package/src/components/InboxMessage/index.tsx +286 -0
- package/src/components/InboxMessage/mock.ts +53 -0
- package/src/components/InboxMessage/style.ts +189 -0
- package/src/components/channel_view/DirectChannelView.tsx +25 -0
- package/src/components/channel_view/PublicChannelView.tsx +24 -0
- package/src/components/dashboard/menu_header.tsx +49 -0
- package/src/components/dashboard/modals/direct_modal.tsx +46 -0
- package/src/components/dashboard/modals.tsx +93 -0
- package/src/components/messenger/avatar/index.tsx +2 -4
- package/src/components/messenger/avatar/style.ts +3 -3
- package/src/components/messenger/index.tsx +258 -94
- package/src/components/messenger/messagesList/index.tsx +673 -249
- package/src/components/messenger/messagesList/messageBox.tsx +2 -1
- package/src/components/messenger/messagesList/style.ts +240 -14
- package/src/components/messenger/more_action/index.tsx +68 -0
- package/src/components/messenger/more_action/style.ts +45 -0
- package/src/components/messenger/postMessage/postMessage.tsx +2 -3
- package/src/components/messenger/postMessage/style.ts +3 -3
- package/src/components/messenger/sidebarThreadList/index.tsx +11 -10
- package/src/components/messenger/style.ts +16 -16
- package/src/components/messenger/threadSidebar/index.tsx +5 -5
- package/src/components/messenger/threadSidebar/style.ts +7 -7
- package/src/components/messenger/types/message.ts +1 -0
- package/src/components/post/channel_intro_message/channel_intro_message.tsx +0 -1
- package/src/components/post/index.tsx +102 -25
- package/src/components/post/post/post.tsx +8 -1
- package/src/components/post/post_header/post_header_custom_status.tsx +1 -2
- package/src/components/post/post_header/style.ts +3 -6
- package/src/components/post/style.ts +22 -8
- package/src/components/post/tutorial/tutorial_tip/tutorial_tip.tsx +1 -0
- package/src/components/post/user_profile/user_profile.tsx +1 -0
- package/src/compute.tsx +58 -37
- package/src/containers/Dashboard.tsx +488 -1
- package/src/containers/Inbox.tsx +13 -0
- package/src/containers/Loading.tsx +1 -1
- package/src/containers/Messenger.tsx +9 -4
- package/src/module.ts +10 -7
- package/src/style.ts +382 -19
- package/src/utils/index.ts +22 -0
- package/src/widgets/badges/badge.tsx +1 -2
- package/src/widgets/badges/style.ts +3 -3
- package/src/widgets/icons/accordion_toggle_icon.tsx +1 -1
- package/src/widgets/icons/add_reaction_icon.tsx +1 -1
- package/src/widgets/icons/admin_eye_icon.tsx +1 -1
- package/src/widgets/icons/alert_icon.tsx +1 -1
- package/src/widgets/icons/archive_icon.tsx +1 -1
- package/src/widgets/icons/arrow_right_icon.tsx +1 -1
- package/src/widgets/icons/at_icon.tsx +1 -1
- package/src/widgets/icons/attachment_icon.tsx +1 -1
- package/src/widgets/icons/back_icon.tsx +1 -1
- package/src/widgets/icons/bot_icon.tsx +1 -1
- package/src/widgets/icons/camera_icon.tsx +1 -1
- package/src/widgets/icons/checkbox_checked_icon.tsx +1 -1
- package/src/widgets/icons/checkbox_partial_icon.tsx +1 -1
- package/src/widgets/icons/close_circle_icon.tsx +1 -1
- package/src/widgets/icons/close_circle_solid_icon.tsx +1 -1
- package/src/widgets/icons/close_icon.tsx +1 -1
- package/src/widgets/icons/dots_horizontal.tsx +1 -1
- package/src/widgets/icons/download_icon.tsx +1 -1
- package/src/widgets/icons/draft_icon.tsx +1 -1
- package/src/widgets/icons/ellipsis_h_icon.tsx +1 -1
- package/src/widgets/icons/email_icon.tsx +1 -1
- package/src/widgets/icons/fa_add_icon.tsx +1 -1
- package/src/widgets/icons/fa_back_icon.tsx +1 -1
- package/src/widgets/icons/fa_dropdown_icon.tsx +1 -1
- package/src/widgets/icons/fa_edit_icon.tsx +1 -1
- package/src/widgets/icons/fa_logout_icon.tsx +1 -1
- package/src/widgets/icons/fa_next_icon.tsx +1 -1
- package/src/widgets/icons/fa_previous_icon.tsx +1 -1
- package/src/widgets/icons/fa_reload_icon.tsx +1 -1
- package/src/widgets/icons/fa_remove_icon.tsx +1 -1
- package/src/widgets/icons/fa_search_icon.tsx +1 -1
- package/src/widgets/icons/fa_select_icon.tsx +1 -1
- package/src/widgets/icons/fa_success_icon.tsx +1 -1
- package/src/widgets/icons/fa_warning_icon.tsx +1 -1
- package/src/widgets/icons/flag_icon.tsx +1 -1
- package/src/widgets/icons/gfycat_icon.tsx +1 -1
- package/src/widgets/icons/gif_reactions_icon.tsx +1 -1
- package/src/widgets/icons/gif_search_clear_icon.tsx +1 -1
- package/src/widgets/icons/gif_search_icon.tsx +1 -1
- package/src/widgets/icons/gif_trending_icon.tsx +1 -1
- package/src/widgets/icons/globe_icon.tsx +1 -1
- package/src/widgets/icons/icons.stories.js +1 -1
- package/src/widgets/icons/info_icon.tsx +1 -1
- package/src/widgets/icons/info_small_icon.tsx +1 -1
- package/src/widgets/icons/invite_icon.tsx +1 -1
- package/src/widgets/icons/invite_members_icon.tsx +1 -1
- package/src/widgets/icons/link_icon.tsx +1 -1
- package/src/widgets/icons/lock_icon.tsx +1 -1
- package/src/widgets/icons/mail_icon.tsx +1 -1
- package/src/widgets/icons/mail_plus_icon.tsx +1 -1
- package/src/widgets/icons/member_icon.tsx +1 -1
- package/src/widgets/icons/mentions_icon.tsx +1 -1
- package/src/widgets/icons/menu_icon.tsx +1 -1
- package/src/widgets/icons/message_icon.tsx +1 -1
- package/src/widgets/icons/pin_icon.tsx +1 -1
- package/src/widgets/icons/plugin_channel_header_icon.tsx +1 -1
- package/src/widgets/icons/plugin_icon.tsx +1 -1
- package/src/widgets/icons/reply_icon.tsx +1 -1
- package/src/widgets/icons/scroll_to_bottom_icon.tsx +1 -1
- package/src/widgets/icons/search_icon.tsx +1 -1
- package/src/widgets/icons/shield_outline_icon.tsx +1 -1
- package/src/widgets/icons/unarchive_icon.tsx +1 -1
- package/src/widgets/icons/unread_below_icon.tsx +1 -1
- package/src/widgets/icons/user_guide_icon.tsx +1 -1
- package/src/widgets/shared_user_indicator.tsx +1 -0
- package/src/widgets/simple_tooltip/simple_tooltip.tsx +1 -0
- package/src/widgets/users/avatar/avatar.tsx +1 -2
- package/src/widgets/users/avatar/style.ts +3 -3
- package/src/widgets/users/avatars/avatars.tsx +1 -0
- package/tsconfig.json +2 -1
- package/webpack.config.js +1 -1
- package/lib/components/messenger/mock.d.ts +0 -50
- package/lib/components/messenger/postMessage/postMessage.d.ts +0 -1
- package/lib/components/messenger/postMessage/style.d.ts +0 -22
- package/lib/components/messenger/sidebarThreadList/index.d.ts +0 -7
- package/lib/components/messenger/threadSidebar/index.d.ts +0 -1
- package/lib/components/messenger/threadSidebar/style.d.ts +0 -62
- package/lib/components/messenger/types/message.d.ts +0 -14
- package/src/api.ts +0 -35
- package/src/components/Counter.tsx +0 -52
- package/src/containers/Clock.tsx +0 -0
- package/src/containers/Counter.tsx +0 -42
- package/src/containers/PersonList.tsx +0 -20
- package/src/containers/ServerCounter.tsx +0 -140
- package/src/graphql/index.ts +0 -3
- package/src/graphql/mutations/addCount.graphql +0 -5
- package/src/graphql/mutations/addPerson.graphql +0 -6
- package/src/graphql/mutations/index.ts +0 -2
- package/src/graphql/queries/count.graphql +0 -5
- package/src/graphql/queries/index.ts +0 -3
- package/src/graphql/queries/person.graphql +0 -22
- package/src/graphql/queries/persons.graphql +0 -6
- package/src/graphql/subscriptions/count.graphql +0 -5
- package/src/graphql/subscriptions/index.ts +0 -1
- package/src/redux/__mocks__/api.ts +0 -4
- package/src/redux/actions/__tests__/sampleActions.test.ts +0 -159
- package/src/redux/actions/index.ts +0 -1
- package/src/redux/actions/sampleActions.ts +0 -91
- package/src/redux/index.ts +0 -2
- package/src/redux/reducers/Store.ts +0 -10
- package/src/redux/reducers/__tests__/sampleReducers.test.ts +0 -39
- package/src/redux/reducers/index.ts +0 -7
- package/src/redux/reducers/sampleReducers.ts +0 -71
- /package/src/components/post/channel_layout/{channel_controller.test.jsx → channel_controller.test.tsx} +0 -0
- /package/src/components/post/channel_layout/{channel_controller.jsx → channel_controller.tsx} +0 -0
|
@@ -1,96 +1,245 @@
|
|
|
1
|
-
import React, {FC, useCallback, useEffect, useRef, useState} from 'react';
|
|
2
|
-
import {Col, Row, Input} from 'antd';
|
|
3
|
-
import {MessagesList, ThreadMessagesList} from './messagesList';
|
|
4
|
-
import {messagesData} from './mock';
|
|
5
|
-
import {IMessageList} from './types/message';
|
|
1
|
+
import React, { FC, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Col, Row, Input } from 'antd';
|
|
6
3
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
4
|
+
useGetMessagesQuery,
|
|
5
|
+
useSendMessagesMutation,
|
|
6
|
+
useDeleteMessageMutation,
|
|
7
|
+
useEditMessageMutation,
|
|
8
|
+
} from '@messenger-box/platform-client';
|
|
9
|
+
import {
|
|
10
|
+
IFileInfo,
|
|
11
|
+
} from '@messenger-box/core';
|
|
12
|
+
import { HiOutlinePaperClip } from 'react-icons/hi';
|
|
13
|
+
import { MdOutlineEmojiEmotions } from 'react-icons/md';
|
|
14
|
+
import { css } from '@emotion/css';
|
|
15
|
+
import { Picker } from 'emoji-mart';
|
|
18
16
|
import 'emoji-mart/css/emoji-mart.css';
|
|
17
|
+
import { useUploadFiles } from '@messenger-box/platform-client';
|
|
18
|
+
import { styleSheet3 } from './messagesList/style';
|
|
19
|
+
import { MessagesList } from './messagesList';
|
|
20
|
+
|
|
21
|
+
interface PropsTypes {
|
|
22
|
+
channel: any;
|
|
23
|
+
currentUsrId: string;
|
|
24
|
+
}
|
|
19
25
|
|
|
20
|
-
export const MessengerComponent: FC = () => {
|
|
26
|
+
export const MessengerComponent: FC<PropsTypes> = ({ channel, currentUsrId }) => {
|
|
21
27
|
document.getElementsByClassName('demo')[0].setAttribute('style', `{{overflow: 'hidden'}}`);
|
|
22
|
-
const {css} = useFela();
|
|
23
28
|
const [enterValue, setEnterValue] = useState<string>('');
|
|
24
29
|
const [showThread, setShowThread] = useState<boolean>(false);
|
|
25
30
|
const [flag, setFlag] = useState<boolean>(false);
|
|
26
|
-
const [userMessagesList, setUserMessagesList] = useState<
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
const [userMessagesList, setUserMessagesList] = useState<any>([]);
|
|
32
|
+
const [chosenEmoji, setChosenEmoji] = useState(null);
|
|
33
|
+
const [displayEmoji, setDisplayEmoji] = useState(false);
|
|
34
|
+
const [day, setDay] = useState<string>('Today');
|
|
35
|
+
const [threadEmoji, setThreadEmoji] = useState(false);
|
|
36
|
+
const [files, setFiles] = useState([])
|
|
37
|
+
const { startUpload } = useUploadFiles();
|
|
38
|
+
|
|
39
|
+
// let token;
|
|
40
|
+
// useEffect(() => {
|
|
41
|
+
// token = window.localStorage.getItem('access_token');
|
|
42
|
+
// }, []);
|
|
43
|
+
const { data, loading, error, refetch } = useGetMessagesQuery({
|
|
44
|
+
variables: {
|
|
45
|
+
channelId: channel.id,
|
|
46
|
+
},
|
|
47
|
+
fetchPolicy: 'cache-first'
|
|
48
|
+
});
|
|
49
|
+
// useEffect(() => {
|
|
50
|
+
// if (isRefetch) {
|
|
51
|
+
// refetch().then((value) => {
|
|
52
|
+
// setUserMessagesList(value.data.messages.data);
|
|
53
|
+
// scrollToBottom();
|
|
54
|
+
// });
|
|
55
|
+
// }
|
|
56
|
+
// }, [isRefetch])
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!loading) {
|
|
59
|
+
setUserMessagesList(data?.messages?.data);
|
|
60
|
+
}
|
|
61
|
+
}, [loading, data]);
|
|
62
|
+
const [sendMsg, sentMessage] = useSendMessagesMutation({
|
|
63
|
+
update: (cache, mutationResult) => {
|
|
64
|
+
setFiles([])
|
|
65
|
+
cache.modify({
|
|
66
|
+
fields: {
|
|
67
|
+
messages(existingMessages, { toReference }) {
|
|
68
|
+
return { ...existingMessages, data: toReference(mutationResult.data.sendMessage) }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
// context: {headers: {Authorization: token}},
|
|
74
|
+
// refetchQueries: ['GetMessages']
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const handleEnterButton = useCallback(async (e) => {
|
|
78
|
+
if (!enterValue) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const { data } = await sendMsg({
|
|
82
|
+
variables: {
|
|
83
|
+
channelId: channel.id,
|
|
84
|
+
content: enterValue,
|
|
85
|
+
files: []
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
const { data: uploadedFiles } = await startUpload({
|
|
89
|
+
file: files,
|
|
90
|
+
saveUploadedFile: {
|
|
91
|
+
variables: {
|
|
92
|
+
postId: data.sendMessage.id
|
|
93
|
+
}
|
|
36
94
|
},
|
|
37
|
-
|
|
95
|
+
createUploadLink: {
|
|
96
|
+
variables: {
|
|
97
|
+
postId: data.sendMessage.id
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
await editMessage({
|
|
102
|
+
variables: {
|
|
103
|
+
channelId: channel.id,
|
|
104
|
+
messageId: data.sendMessage.id,
|
|
105
|
+
files: (uploadedFiles as unknown as IFileInfo[]).map(i => i.id),
|
|
106
|
+
content: enterValue
|
|
107
|
+
}
|
|
108
|
+
})
|
|
38
109
|
setEnterValue('');
|
|
110
|
+
scrollToBottom();
|
|
39
111
|
setFlag(true);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
112
|
+
}, [channel, files, enterValue]);
|
|
113
|
+
|
|
114
|
+
const [deleteMsg, { }] = useDeleteMessageMutation({
|
|
115
|
+
// context: {headers: {Authorization: token}},
|
|
116
|
+
// refetchQueries: ['GetMessages']
|
|
117
|
+
});
|
|
118
|
+
const handleDeleteMessage = (id) => {
|
|
119
|
+
deleteMsg({
|
|
120
|
+
variables: {
|
|
121
|
+
channelId: channel.id,
|
|
122
|
+
messageId: id,
|
|
123
|
+
},
|
|
124
|
+
})
|
|
44
125
|
};
|
|
45
|
-
|
|
46
|
-
|
|
126
|
+
const onEmojiClick = (event, emojiObject) => {
|
|
127
|
+
setChosenEmoji(emojiObject);
|
|
47
128
|
};
|
|
48
|
-
const [
|
|
49
|
-
|
|
50
|
-
|
|
129
|
+
const [editMessage, { }] = useEditMessageMutation({
|
|
130
|
+
// refetchQueries: ['GetMessages']
|
|
131
|
+
});
|
|
132
|
+
const clickRef = useRef();
|
|
133
|
+
const checkIfClickedOutside = (e) => {
|
|
134
|
+
const node = clickRef.current as any;
|
|
135
|
+
if (node && node.contains(e.target)) {
|
|
136
|
+
setDisplayEmoji(false);
|
|
137
|
+
setThreadEmoji(false);
|
|
138
|
+
} else {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (displayEmoji || threadEmoji) {
|
|
144
|
+
document.addEventListener('click', checkIfClickedOutside, false);
|
|
145
|
+
} else {
|
|
146
|
+
document.removeEventListener('click', checkIfClickedOutside, false);
|
|
147
|
+
}
|
|
148
|
+
return () => {
|
|
149
|
+
document.removeEventListener('click', checkIfClickedOutside, false);
|
|
150
|
+
};
|
|
151
|
+
}, [displayEmoji, threadEmoji]);
|
|
152
|
+
const handleOnSelect = (emoji) => {
|
|
153
|
+
setEnterValue(enterValue + emoji.native);
|
|
154
|
+
// setDisplayEmoji(false);
|
|
155
|
+
};
|
|
156
|
+
const emojiClick = (type) => {
|
|
157
|
+
if (type === 'main') {
|
|
158
|
+
setDisplayEmoji(true);
|
|
159
|
+
}
|
|
160
|
+
if (type === 'thread') {
|
|
161
|
+
setThreadEmoji(true);
|
|
162
|
+
}
|
|
51
163
|
};
|
|
52
164
|
const messagesEndRef = useRef(null);
|
|
53
165
|
const scrollToBottom = () => {
|
|
54
|
-
messagesEndRef.current?.scrollIntoView({behavior: 'smooth'});
|
|
166
|
+
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
55
167
|
};
|
|
56
|
-
|
|
57
|
-
if (flag === true) {
|
|
58
|
-
setTimeout(() => {
|
|
59
|
-
setUserMessagesList([
|
|
60
|
-
...userMessagesList,
|
|
61
|
-
{
|
|
62
|
-
id: Math.random(),
|
|
63
|
-
loginUser: false,
|
|
64
|
-
message: 'Thank for chatting with us',
|
|
65
|
-
timeIsToday: true,
|
|
66
|
-
isReply: false,
|
|
67
|
-
},
|
|
68
|
-
]);
|
|
69
|
-
setFlag(false);
|
|
70
|
-
}, 200);
|
|
71
|
-
}
|
|
72
|
-
scrollToBottom();
|
|
73
|
-
}, [flag]);
|
|
168
|
+
|
|
74
169
|
const fileUploader = useRef(null);
|
|
75
170
|
const fileClick = () => {
|
|
76
171
|
fileUploader.current.click();
|
|
77
172
|
};
|
|
78
173
|
|
|
79
174
|
const handleShowSideBar = () => {
|
|
80
|
-
setShowThread(!showThread)
|
|
175
|
+
setShowThread(!showThread);
|
|
176
|
+
};
|
|
177
|
+
const handleEditMessage = useCallback(async (id, msg) => {
|
|
178
|
+
const { data: uploadedFiles } = await startUpload({
|
|
179
|
+
file: files,
|
|
180
|
+
saveUploadedFile: {
|
|
181
|
+
variables: {
|
|
182
|
+
ref: id,
|
|
183
|
+
refName: 'postId'
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
return editMessage({
|
|
188
|
+
variables: {
|
|
189
|
+
channelId: channel.id,
|
|
190
|
+
messageId: id,
|
|
191
|
+
content: msg,
|
|
192
|
+
files: (uploadedFiles as unknown as IFileInfo[]).map(i => i.id),
|
|
193
|
+
},
|
|
194
|
+
})
|
|
195
|
+
}, [files, channel]);
|
|
196
|
+
|
|
197
|
+
const handleFileChange = (e) => {
|
|
198
|
+
let inputFiles: any = []
|
|
199
|
+
Object.keys(e.target.files).map((key) => inputFiles.push(e.target.files[key]));
|
|
200
|
+
setFiles([...inputFiles])
|
|
201
|
+
}
|
|
202
|
+
const previewClose = (file) => {
|
|
203
|
+
setFiles([...files.filter(f => f !== file)])
|
|
81
204
|
}
|
|
82
205
|
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
let imgs = document.getElementById('preview_img')
|
|
208
|
+
imgs.innerHTML = ''
|
|
209
|
+
files.forEach((f, index) => {
|
|
210
|
+
let childDiv = document.createElement('div')
|
|
211
|
+
childDiv.className = 'child_div'
|
|
212
|
+
let childImg = document.createElement('img')
|
|
213
|
+
childImg.src = URL.createObjectURL(f)
|
|
214
|
+
let childClose = document.createElement('i')
|
|
215
|
+
childClose.className = 'fa fa-times'
|
|
216
|
+
let overLayDiv = document.createElement('div')
|
|
217
|
+
overLayDiv.className = 'overlay'
|
|
218
|
+
childClose.onclick = () => previewClose(f)
|
|
219
|
+
childDiv.appendChild(overLayDiv)
|
|
220
|
+
childDiv.appendChild(childImg)
|
|
221
|
+
childDiv.appendChild(childClose)
|
|
222
|
+
imgs.appendChild(childDiv)
|
|
223
|
+
})
|
|
224
|
+
}, [files])
|
|
83
225
|
|
|
226
|
+
console.log(channel)
|
|
84
227
|
return (
|
|
85
|
-
<div className={css(styleSheet3.customInputStyle
|
|
228
|
+
<div className={css(styleSheet3.customInputStyle)} ref={clickRef}>
|
|
86
229
|
<div className="chat_container">
|
|
87
230
|
<div className="left_chat_box">
|
|
88
231
|
<div className="msg_list">
|
|
89
232
|
<Row gutter={[24, 6]} className="msg_row">
|
|
90
233
|
<Col>
|
|
91
|
-
<MessagesList
|
|
92
|
-
|
|
93
|
-
|
|
234
|
+
<MessagesList
|
|
235
|
+
channel={channel}
|
|
236
|
+
userMessagesList={userMessagesList}
|
|
237
|
+
handleShowSideBar={handleShowSideBar}
|
|
238
|
+
handleDeleteMessage={handleDeleteMessage}
|
|
239
|
+
handleEditMessage={handleEditMessage}
|
|
240
|
+
currentUsrId={currentUsrId}
|
|
241
|
+
/>
|
|
242
|
+
<div ref={messagesEndRef} />
|
|
94
243
|
</Col>
|
|
95
244
|
</Row>
|
|
96
245
|
</div>
|
|
@@ -99,6 +248,7 @@ export const MessengerComponent: FC = () => {
|
|
|
99
248
|
<div className="input_class">
|
|
100
249
|
{displayEmoji ? (
|
|
101
250
|
<Picker
|
|
251
|
+
onSelect={handleOnSelect}
|
|
102
252
|
native={true}
|
|
103
253
|
set="apple"
|
|
104
254
|
emoji="point_up"
|
|
@@ -114,52 +264,64 @@ export const MessengerComponent: FC = () => {
|
|
|
114
264
|
) : (
|
|
115
265
|
''
|
|
116
266
|
)}
|
|
117
|
-
<
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
267
|
+
<div className="input_msg">
|
|
268
|
+
<div style={{ display: 'flex', position: 'relative' }}>
|
|
269
|
+
<Input
|
|
270
|
+
value={enterValue}
|
|
271
|
+
onChange={(e: any) => setEnterValue(e?.target?.value)}
|
|
272
|
+
onPressEnter={(e) => handleEnterButton(e)}
|
|
273
|
+
placeholder="Please Enter"
|
|
274
|
+
className="msg_input"
|
|
275
|
+
/>
|
|
276
|
+
<div className="icon_box">
|
|
277
|
+
<div className="icon_style">
|
|
278
|
+
<input type="file" onChange={handleFileChange} ref={fileUploader}
|
|
279
|
+
style={{ display: 'none' }} multiple={true} />
|
|
280
|
+
<button style={{ border: '0px' }} onClick={fileClick}>
|
|
281
|
+
<HiOutlinePaperClip />
|
|
282
|
+
</button>
|
|
283
|
+
</div>
|
|
284
|
+
<div className="icon_style">
|
|
285
|
+
<button style={{ border: '0px' }} onClick={(e) => emojiClick('main')}>
|
|
286
|
+
<MdOutlineEmojiEmotions />
|
|
287
|
+
</button>
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
135
290
|
</div>
|
|
291
|
+
<div id="preview_img" className="preview_imgs"></div>
|
|
136
292
|
</div>
|
|
137
293
|
</div>
|
|
138
294
|
</Col>
|
|
139
295
|
</Row>
|
|
140
296
|
</div>
|
|
141
|
-
{showThread ?
|
|
297
|
+
{/*{showThread ? (
|
|
142
298
|
<div className="right_chat_box">
|
|
143
299
|
<div className="thread_head">
|
|
144
300
|
<div>
|
|
145
301
|
<span>Thread</span>
|
|
146
302
|
<button>surveybot</button>
|
|
147
303
|
</div>
|
|
148
|
-
<button onClick={handleShowSideBar} style={{border: '0px', fontSize: '20px'}}>
|
|
149
|
-
<IoIosClose/>
|
|
304
|
+
<button onClick={handleShowSideBar} style={{ border: '0px', fontSize: '20px' }}>
|
|
305
|
+
<IoIosClose />
|
|
150
306
|
</button>
|
|
151
307
|
</div>
|
|
152
308
|
<div className="msg_list">
|
|
153
309
|
<Row gutter={[24, 6]} className="msg_row">
|
|
154
310
|
<Col>
|
|
155
|
-
<ThreadMessagesList
|
|
156
|
-
|
|
157
|
-
|
|
311
|
+
<ThreadMessagesList
|
|
312
|
+
userMessagesList={userMessagesList}
|
|
313
|
+
handleShowSideBar={handleShowSideBar}
|
|
314
|
+
handleDeleteMessage={handleDeleteMessage}
|
|
315
|
+
handleEditMessage={{}}
|
|
316
|
+
channel={channel}
|
|
317
|
+
/>
|
|
318
|
+
<div ref={messagesEndRef} />
|
|
158
319
|
</Col>
|
|
159
320
|
<Col className="thread_input_row">
|
|
160
321
|
<div className="input_class">
|
|
161
|
-
{
|
|
322
|
+
{threadEmoji ? (
|
|
162
323
|
<Picker
|
|
324
|
+
onSelect={handleOnSelect}
|
|
163
325
|
native={true}
|
|
164
326
|
set="apple"
|
|
165
327
|
emoji="point_up"
|
|
@@ -184,14 +346,14 @@ export const MessengerComponent: FC = () => {
|
|
|
184
346
|
/>
|
|
185
347
|
<div className="icon_box">
|
|
186
348
|
<div className="icon_style">
|
|
187
|
-
<input type="file" ref={fileUploader} style={{display: 'none'}}/>
|
|
188
|
-
<button style={{border: '0px'}} onClick={fileClick}>
|
|
189
|
-
<HiOutlinePaperClip/>
|
|
349
|
+
<input type="file" ref={fileUploader} style={{ display: 'none' }} />
|
|
350
|
+
<button style={{ border: '0px' }} onClick={fileClick}>
|
|
351
|
+
<HiOutlinePaperClip />
|
|
190
352
|
</button>
|
|
191
353
|
</div>
|
|
192
354
|
<div className="icon_style">
|
|
193
|
-
<button style={{border: '0px'}} onClick={emojiClick}>
|
|
194
|
-
<MdOutlineEmojiEmotions/>
|
|
355
|
+
<button style={{ border: '0px' }} onClick={(e) => emojiClick('thread')}>
|
|
356
|
+
<MdOutlineEmojiEmotions />
|
|
195
357
|
</button>
|
|
196
358
|
</div>
|
|
197
359
|
</div>
|
|
@@ -199,8 +361,10 @@ export const MessengerComponent: FC = () => {
|
|
|
199
361
|
</Col>
|
|
200
362
|
</Row>
|
|
201
363
|
</div>
|
|
202
|
-
</div>
|
|
203
|
-
|
|
364
|
+
</div>
|
|
365
|
+
) : (
|
|
366
|
+
''
|
|
367
|
+
)}*/}
|
|
204
368
|
</div>
|
|
205
369
|
</div>
|
|
206
370
|
);
|