@messenger-box/platform-mobile 0.0.1-alpha.310 → 0.0.1-alpha.314
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 +8 -0
- package/lib/index.js +431 -68
- package/lib/index.js.map +1 -1
- package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.d.ts +32 -0
- package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.d.ts +23 -0
- package/lib/screens/inbox/components/SlackMessageContainer/index.d.ts +2 -0
- package/lib/screens/inbox/containers/Dialogs.d.ts +1 -2
- package/package.json +4 -4
- package/src/screens/inbox/components/DialogsListItem.tsx +109 -53
- package/src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx +242 -0
- package/src/screens/inbox/components/SlackMessageContainer/SlackMessage.tsx +115 -0
- package/src/screens/inbox/components/SlackMessageContainer/index.ts +2 -0
- package/src/screens/inbox/containers/ConversationView.tsx +32 -9
- package/src/screens/inbox/containers/Dialogs.tsx +49 -54
|
@@ -2,10 +2,10 @@ import React, { useCallback, useMemo, useEffect, useState } from 'react';
|
|
|
2
2
|
import { FlatList, Box, Heading, Input, Text, Icon, Center } from 'native-base';
|
|
3
3
|
import { Ionicons } from '@expo/vector-icons';
|
|
4
4
|
import { useSelector, useDispatch } from 'react-redux';
|
|
5
|
-
import { useNavigation, useRoute, useIsFocused } from '@react-navigation/native';
|
|
5
|
+
import { useNavigation, useRoute, useIsFocused, useFocusEffect } from '@react-navigation/native';
|
|
6
6
|
|
|
7
7
|
import { DialogsListItem } from '../components/DialogsListItem';
|
|
8
|
-
import {
|
|
8
|
+
import { useGetChannelsByUserQuery } from '@messenger-box/platform-client';
|
|
9
9
|
import { userSelector } from '@adminide-stack/user-auth0-client';
|
|
10
10
|
import { CHANGE_SETTINGS_ACTION } from '@admin-layout/client';
|
|
11
11
|
import { config } from '../config';
|
|
@@ -15,7 +15,7 @@ export interface InboxProps {
|
|
|
15
15
|
channelRole?: string;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export
|
|
18
|
+
export const Dialogs = (props: InboxProps) => {
|
|
19
19
|
const { channelFilters, channelRole } = props;
|
|
20
20
|
const { params } = useRoute<any>();
|
|
21
21
|
const auth = useSelector(userSelector);
|
|
@@ -35,17 +35,18 @@ export function Dialogs(props: InboxProps) {
|
|
|
35
35
|
},
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
useFocusEffect(
|
|
39
|
+
React.useCallback(() => {
|
|
40
|
+
// Do something when the screen is focused
|
|
41
|
+
getChannelsRefetch({ role: channelRole, criteria: channelFilters });
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
return () => {
|
|
44
|
+
// Do something when the screen is unfocused
|
|
45
|
+
// Useful for cleanup functions
|
|
46
|
+
};
|
|
47
|
+
}, [channelFilters]),
|
|
43
48
|
);
|
|
44
49
|
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
getChannelsRefetch();
|
|
47
|
-
}, [isFocused, navigation]);
|
|
48
|
-
|
|
49
50
|
useEffect(() => {
|
|
50
51
|
setTimeout(() => {
|
|
51
52
|
dispatch({
|
|
@@ -67,11 +68,13 @@ export function Dialogs(props: InboxProps) {
|
|
|
67
68
|
|
|
68
69
|
useEffect(() => {
|
|
69
70
|
if (userChannels?.channelsByUser) {
|
|
70
|
-
//Direct channel
|
|
71
|
+
//Direct channel
|
|
71
72
|
let userDirectChannels: any =
|
|
72
73
|
userChannels?.channelsByUser
|
|
73
74
|
?.filter((i: any) => i.type == 'DIRECT')
|
|
74
|
-
?.filter((c: any) =>
|
|
75
|
+
?.filter((c: any) =>
|
|
76
|
+
c.members.some((u: any) => u?.user?.id != auth?.id && u.user.__typename == 'UserAccount'),
|
|
77
|
+
) ?? [];
|
|
75
78
|
|
|
76
79
|
if (userDirectChannels?.length > 0) setUserDirectChannel(userDirectChannels);
|
|
77
80
|
}
|
|
@@ -93,49 +96,41 @@ export function Dialogs(props: InboxProps) {
|
|
|
93
96
|
}
|
|
94
97
|
}, []);
|
|
95
98
|
|
|
96
|
-
//let cuc = userChannels?.channelsByUser?.filter((i:any)=>i.type=='DIRECT')?.map((k:any) => k?.members?.filter((e:any) => e?.user?.id != currentUser?.id))??[];
|
|
97
|
-
let cuc = userDirectChannel?.map((k: any) => k?.members?.filter((e: any) => e?.user?.id != currentUser?.id)) ?? [];
|
|
98
|
-
cuc = cuc.filter((e: any) => e.length);
|
|
99
99
|
return (
|
|
100
100
|
<Box p={2}>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
<FlatList
|
|
102
|
+
data={userDirectChannel?.length > 0 ? userDirectChannel : []}
|
|
103
|
+
onRefresh={getChannelsRefetch}
|
|
104
|
+
refreshing={userChannelsLoading}
|
|
105
|
+
contentContainerStyle={{ minHeight: '100%' }}
|
|
106
|
+
ItemSeparatorComponent={() => <Box height="0.5" backgroundColor="gray.200" />}
|
|
107
|
+
renderItem={({ item: channel }) => (
|
|
108
|
+
<DialogsListItem
|
|
109
|
+
onOpen={handleSelectChannel}
|
|
110
|
+
currentUser={auth}
|
|
111
|
+
channel={channel}
|
|
112
|
+
selectedChannelId={params?.channelId}
|
|
112
113
|
/>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
selectedChannelId={params?.channelId}
|
|
134
|
-
/>
|
|
135
|
-
)}
|
|
136
|
-
/>
|
|
137
|
-
</>
|
|
138
|
-
)}
|
|
114
|
+
)}
|
|
115
|
+
ListEmptyComponent={() => (
|
|
116
|
+
<Box p={5}>
|
|
117
|
+
<Heading>Chat</Heading>
|
|
118
|
+
<Input
|
|
119
|
+
height={50}
|
|
120
|
+
mt={3}
|
|
121
|
+
placeholder="Search"
|
|
122
|
+
borderRadius={50}
|
|
123
|
+
borderColor={'gray.200'}
|
|
124
|
+
borderWidth={2}
|
|
125
|
+
/>
|
|
126
|
+
<Center mt={6}>
|
|
127
|
+
<Icon as={Ionicons} name="chatbubbles" size={'xl'} />
|
|
128
|
+
<Text>You don't have any messages yet!</Text>
|
|
129
|
+
</Center>
|
|
130
|
+
</Box>
|
|
131
|
+
)}
|
|
132
|
+
keyExtractor={(item, index) => 'key' + index}
|
|
133
|
+
/>
|
|
139
134
|
</Box>
|
|
140
135
|
);
|
|
141
|
-
}
|
|
136
|
+
};
|