@tellescope/chat 1.3.5 → 1.3.8

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.5",
3
+ "version": "1.3.8",
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.5",
39
- "@tellescope/sdk": "^1.3.3",
40
- "@tellescope/types-client": "^1.3.3",
41
- "@tellescope/types-models": "^1.3.3",
37
+ "@tellescope/constants": "^1.3.8",
38
+ "@tellescope/react-components": "^1.3.8",
39
+ "@tellescope/sdk": "^1.3.8",
40
+ "@tellescope/types-client": "^1.3.8",
41
+ "@tellescope/types-models": "^1.3.8",
42
42
  "@tellescope/types-utilities": "^1.2.2",
43
- "@tellescope/utilities": "^1.3.3",
43
+ "@tellescope/utilities": "^1.3.8",
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": "840b57b6260a5de2f5785b8495cd4954a240a014",
54
+ "gitHead": "f3bbed31c815d4eb0bfde87b5ad9f668277aff7c",
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 = ({
@@ -183,22 +185,16 @@ export const SendMessage = ({
183
185
  )
184
186
  }
185
187
 
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 = ({
188
+ export const CreateChatRoom = ({
195
189
  excludeEndusers,
196
190
  excludeUsers,
197
191
  onGoBack,
198
192
  onSuccess,
199
193
  onError=console.error,
200
- roomTitle="Group Chat"
201
- }: CreateGroupChatProps) => {
194
+ roomTitle="Group Chat",
195
+ radio,
196
+ }: CreateChatRoomProps) => {
197
+ const session = useResolvedSession()
202
198
  const [, { createElement: createRoom }] = useChatRooms()
203
199
  const [endusersLoading] = useEndusers()
204
200
  const [usersLoading] = useUsers()
@@ -227,9 +223,15 @@ export const CreateGroupChat = ({
227
223
  const userIds = selected.filter(s => users.find(u => u.id === s))
228
224
  const enduserIds = selected.filter(s => endusers.find(u => u.id === s))
229
225
 
226
+ if (session.type === 'enduser') {
227
+ enduserIds.push(session.userInfo.id)
228
+ } else {
229
+ userIds.push(session.userInfo.id)
230
+ }
231
+
230
232
  createRoom({
231
233
  enduserIds,
232
- userIds,
234
+ userIds,
233
235
  title: roomTitle,
234
236
  })
235
237
  .then(r => {
@@ -241,32 +243,37 @@ export const CreateGroupChat = ({
241
243
  />
242
244
  </Flex>
243
245
 
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,
246
+ <List items={[...excludeUsers ? [] : users, ... excludeEndusers ? [] : endusers].filter(u => u.id !== session.userInfo.id)}
247
+ render={user => (
248
+ <Paper flex elevation={5} style={{
249
+ marginBottom: 2,
264
250
  }}>
265
- {user_display_name(user)}
266
- </Typography>
267
- </Flex>
268
- </Paper>
269
- )} />
251
+ <Flex flex={1} alignItems="center" justifyContent="space-between"
252
+ onClick={() => setSelected(ss => (
253
+ ss.includes(user.id)
254
+ ? radio
255
+ ? []
256
+ : ss.filter(s => s !== user.id)
257
+ :radio
258
+ ? [user.id]
259
+ : [user.id, ...ss]
260
+ ))}
261
+ style={{
262
+ paddingLeft: 5, paddingRight: 5,
263
+ }}
264
+ >
265
+ <RadioButton value={user.id}
266
+ status={selected.includes(user.id) ? 'checked' : 'unchecked'}
267
+ />
268
+
269
+ <Typography style={{
270
+ fontWeight: selected.includes(user.id) ? 'bold' : undefined,
271
+ }}>
272
+ {user_display_name(user)}
273
+ </Typography>
274
+ </Flex>
275
+ </Paper>
276
+ )} />
270
277
  </Flex>
271
278
  )} />
272
279
  )
@@ -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
  }