@tellescope/chat 1.3.6 → 1.3.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/chat",
3
- "version": "1.3.6",
3
+ "version": "1.3.9",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -34,13 +34,13 @@
34
34
  "@fontsource/roboto": "^4.5.1",
35
35
  "@mui/icons-material": "^5.0.1",
36
36
  "@mui/material": "^5.0.2",
37
- "@tellescope/constants": "^1.3.3",
38
- "@tellescope/react-components": "^1.3.6",
39
- "@tellescope/sdk": "^1.3.6",
40
- "@tellescope/types-client": "^1.3.3",
41
- "@tellescope/types-models": "^1.3.3",
37
+ "@tellescope/constants": "^1.3.9",
38
+ "@tellescope/react-components": "^1.3.9",
39
+ "@tellescope/sdk": "^1.3.9",
40
+ "@tellescope/types-client": "^1.3.9",
41
+ "@tellescope/types-models": "^1.3.9",
42
42
  "@tellescope/types-utilities": "^1.2.2",
43
- "@tellescope/utilities": "^1.3.6",
43
+ "@tellescope/utilities": "^1.3.9",
44
44
  "@typescript-eslint/eslint-plugin": "^4.33.0",
45
45
  "@typescript-eslint/parser": "^4.33.0",
46
46
  "eslint": "^7.32.0",
@@ -51,7 +51,7 @@
51
51
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
52
52
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
53
53
  },
54
- "gitHead": "4cc8d92a569718468e809e4604e93f2655674603",
54
+ "gitHead": "d7763c597c38536aaa0e076548c33b6f19944fb6",
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  }
@@ -18,12 +18,14 @@ import {
18
18
  LoadingData,
19
19
  useChatRooms,
20
20
  APIError,
21
- LoadingButton,
21
+ LoadingButton,
22
+ useResolvedSession,
22
23
  } from "@tellescope/react-components"
23
24
  import { useState } from 'react';
24
25
  import { ChatRoom } from '@tellescope/types-client';
25
26
  import { render } from 'react-dom';
26
27
  import { user_display_name } from '@tellescope/utilities';
28
+ import { CreateChatRoomProps } from './components';
27
29
 
28
30
  const CHAT_ICON_SIZE = 35
29
31
  const SendImageOrVideo = ({
@@ -94,14 +96,18 @@ const SendImageOrVideo = ({
94
96
  style={{ marginBottom: 20 }}
95
97
  >
96
98
  <View style={{ flexDirection: 'row', alignItems: 'center', minHeight: 40 }}>
97
- <Typography style={{ fontSize: 18, marginRight: 10 }}>Upload</Typography>
98
- <Avatar.Icon icon="image" size={CHAT_ICON_SIZE} />
99
+ <Typography style={{ fontSize: 18, marginRight: 10, color: 'white' }}>
100
+ Upload
101
+ </Typography>
102
+ <Avatar.Icon icon="image" color="white" size={CHAT_ICON_SIZE} />
99
103
  </View>
100
104
  </Button>
101
105
  <Button disabled={menuDisabled} variant="contained" onPress={() => handleImageSelect('camera')}>
102
106
  <View style={{ flexDirection: 'row', alignItems: 'center', minHeight: 40 }}>
103
- <Typography style={{ fontSize: 18, marginRight: 10 }}>Take Photo</Typography>
104
- <Avatar.Icon icon="camera" size={CHAT_ICON_SIZE} />
107
+ <Typography style={{ fontSize: 18, marginRight: 10, color: 'white' }}>
108
+ Take Photo
109
+ </Typography>
110
+ <Avatar.Icon icon="camera" color="white" size={CHAT_ICON_SIZE} />
105
111
  </View>
106
112
  </Button>
107
113
  <Button variant='outlined' onPress={() => setMenuOpen(false)} style={{ marginTop: 25 }}>
@@ -183,22 +189,16 @@ export const SendMessage = ({
183
189
  )
184
190
  }
185
191
 
186
- export interface CreateGroupChatProps {
187
- excludeEndusers?: boolean,
188
- excludeUsers?: boolean,
189
- onGoBack?: () => void,
190
- onSuccess?: (c: ChatRoom) => void,
191
- onError?: (e: APIError) => void,
192
- roomTitle?: string,
193
- }
194
- export const CreateGroupChat = ({
192
+ export const CreateChatRoom = ({
195
193
  excludeEndusers,
196
194
  excludeUsers,
197
195
  onGoBack,
198
196
  onSuccess,
199
197
  onError=console.error,
200
- roomTitle="Group Chat"
201
- }: CreateGroupChatProps) => {
198
+ roomTitle="Group Chat",
199
+ radio,
200
+ }: CreateChatRoomProps) => {
201
+ const session = useResolvedSession()
202
202
  const [, { createElement: createRoom }] = useChatRooms()
203
203
  const [endusersLoading] = useEndusers()
204
204
  const [usersLoading] = useUsers()
@@ -227,9 +227,15 @@ export const CreateGroupChat = ({
227
227
  const userIds = selected.filter(s => users.find(u => u.id === s))
228
228
  const enduserIds = selected.filter(s => endusers.find(u => u.id === s))
229
229
 
230
+ if (session.type === 'enduser') {
231
+ enduserIds.push(session.userInfo.id)
232
+ } else {
233
+ userIds.push(session.userInfo.id)
234
+ }
235
+
230
236
  createRoom({
231
237
  enduserIds,
232
- userIds,
238
+ userIds,
233
239
  title: roomTitle,
234
240
  })
235
241
  .then(r => {
@@ -241,32 +247,37 @@ export const CreateGroupChat = ({
241
247
  />
242
248
  </Flex>
243
249
 
244
- <List items={[...excludeUsers ? [] : users, ... excludeEndusers ? [] : endusers]} render={user => (
245
- <Paper flex elevation={5} style={{
246
- marginBottom: 2,
247
- }}>
248
- <Flex flex={1} alignItems="center" justifyContent="space-between"
249
- onClick={() => setSelected(ss => (
250
- ss.includes(user.id)
251
- ? ss.filter(s => s !== user.id)
252
- : [user.id, ...ss]
253
- ))}
254
- style={{
255
- paddingLeft: 5, paddingRight: 5,
256
- }}
257
- >
258
- <RadioButton value={user.id}
259
- status={selected.includes(user.id) ? 'checked' : 'unchecked'}
260
- />
261
-
262
- <Typography style={{
263
- fontWeight: selected.includes(user.id) ? 'bold' : undefined,
250
+ <List items={[...excludeUsers ? [] : users, ... excludeEndusers ? [] : endusers].filter(u => u.id !== session.userInfo.id)}
251
+ render={user => (
252
+ <Paper flex elevation={5} style={{
253
+ marginBottom: 2,
264
254
  }}>
265
- {user_display_name(user)}
266
- </Typography>
267
- </Flex>
268
- </Paper>
269
- )} />
255
+ <Flex flex={1} alignItems="center" justifyContent="space-between"
256
+ onClick={() => setSelected(ss => (
257
+ ss.includes(user.id)
258
+ ? radio
259
+ ? []
260
+ : ss.filter(s => s !== user.id)
261
+ :radio
262
+ ? [user.id]
263
+ : [user.id, ...ss]
264
+ ))}
265
+ style={{
266
+ paddingLeft: 5, paddingRight: 5,
267
+ }}
268
+ >
269
+ <RadioButton value={user.id}
270
+ status={selected.includes(user.id) ? 'checked' : 'unchecked'}
271
+ />
272
+
273
+ <Typography style={{
274
+ fontWeight: selected.includes(user.id) ? 'bold' : undefined,
275
+ }}>
276
+ {user_display_name(user)}
277
+ </Typography>
278
+ </Flex>
279
+ </Paper>
280
+ )} />
270
281
  </Flex>
271
282
  )} />
272
283
  )
@@ -1,12 +1,16 @@
1
1
  import React, { CSSProperties, useEffect, useState } from "react"
2
- import { ChatMessage } from "@tellescope/types-client";
2
+ import { ChatMessage, ChatRoom } from "@tellescope/types-client";
3
3
 
4
4
  import {
5
+ APIError,
5
6
  AsyncIconButton,
6
7
  Flex,
7
8
  SendIcon,
8
9
  TextField,
10
+ useChatRooms,
9
11
  useChats,
12
+ useEndusers,
13
+ useUsers,
10
14
  } from "@tellescope/react-components"
11
15
 
12
16
  interface SendMessage_T {
@@ -85,4 +89,95 @@ export const SendMessage = ({
85
89
  </Flex>
86
90
  </Flex>
87
91
  )
92
+ }
93
+
94
+ export interface CreateChatRoomProps {
95
+ excludeEndusers?: boolean,
96
+ excludeUsers?: boolean,
97
+ onGoBack?: () => void,
98
+ onSuccess?: (c: ChatRoom) => void,
99
+ onError?: (e: APIError) => void,
100
+ roomTitle?: string,
101
+ radio?: boolean,
102
+ }
103
+ export const CreateChatRoom: React.JSXElementConstructor<CreateChatRoomProps> = ({
104
+ excludeEndusers,
105
+ excludeUsers,
106
+ onGoBack,
107
+ onSuccess,
108
+ onError=console.error,
109
+ roomTitle="Group Chat",
110
+ }) => {
111
+ return null
112
+ // const [, { createElement: createRoom }] = useChatRooms()
113
+ // const [endusersLoading] = useEndusers()
114
+ // const [usersLoading] = useUsers()
115
+
116
+ // const [selected, setSelected] = useState<string[]>([])
117
+
118
+ // return (
119
+ // <LoadingData data={{ endusers: endusersLoading, users: usersLoading }} render={({ users, endusers }) => (
120
+ // <Flex flex={1} column>
121
+ // <Flex alignItems="center" justifyContent={"space-between"} style={{
122
+ // marginBottom: 10,
123
+ // }}>
124
+ // {onGoBack &&
125
+ // <Button onClick={onGoBack}>
126
+ // Back
127
+ // </Button>
128
+ // }
129
+ // <Typography style={{ fontSize: 20, textAlign: 'center' }}>
130
+ // Select Members
131
+ // </Typography>
132
+
133
+ // <LoadingButton submitText='Create' submittingText='Create'
134
+ // disabled={selected.length === 0}
135
+ // style={{ display: 'flex', marginRight: 5 }}
136
+ // onClick={() => {
137
+ // const userIds = selected.filter(s => users.find(u => u.id === s))
138
+ // const enduserIds = selected.filter(s => endusers.find(u => u.id === s))
139
+
140
+ // createRoom({
141
+ // enduserIds,
142
+ // userIds,
143
+ // title: roomTitle,
144
+ // })
145
+ // .then(r => {
146
+ // setSelected([])
147
+ // onSuccess?.(r)
148
+ // })
149
+ // .catch(onError)
150
+ // }}
151
+ // />
152
+ // </Flex>
153
+
154
+ // <List items={[...excludeUsers ? [] : users, ... excludeEndusers ? [] : endusers]} render={user => (
155
+ // <Paper flex elevation={5} style={{
156
+ // marginBottom: 2,
157
+ // }}>
158
+ // <Flex flex={1} alignItems="center" justifyContent="space-between"
159
+ // onClick={() => setSelected(ss => (
160
+ // ss.includes(user.id)
161
+ // ? ss.filter(s => s !== user.id)
162
+ // : [user.id, ...ss]
163
+ // ))}
164
+ // style={{
165
+ // paddingLeft: 5, paddingRight: 5,
166
+ // }}
167
+ // >
168
+ // <RadioButton value={user.id}
169
+ // status={selected.includes(user.id) ? 'checked' : 'unchecked'}
170
+ // />
171
+
172
+ // <Typography style={{
173
+ // fontWeight: selected.includes(user.id) ? 'bold' : undefined,
174
+ // }}>
175
+ // {user_display_name(user)}
176
+ // </Typography>
177
+ // </Flex>
178
+ // </Paper>
179
+ // )} />
180
+ // </Flex>
181
+ // )} />
182
+ // )
88
183
  }