@tellescope/chat 0.0.43 → 0.0.46
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/lib/cjs/chat.d.ts +7 -5
- package/lib/cjs/chat.d.ts.map +1 -1
- package/lib/cjs/chat.js +14 -31
- package/lib/cjs/chat.js.map +1 -1
- package/lib/esm/chat.d.ts +7 -5
- package/lib/esm/chat.d.ts.map +1 -1
- package/lib/esm/chat.js +16 -33
- package/lib/esm/chat.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/chat.tsx +32 -47
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/chat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"@fontsource/roboto": "^4.5.1",
|
|
34
34
|
"@mui/icons-material": "^5.0.1",
|
|
35
35
|
"@mui/material": "^5.0.2",
|
|
36
|
-
"@tellescope/constants": "^0.0.
|
|
37
|
-
"@tellescope/react-components": "^0.0.
|
|
38
|
-
"@tellescope/sdk": "^0.0.
|
|
39
|
-
"@tellescope/types-client": "^0.0.
|
|
40
|
-
"@tellescope/types-models": "^0.0.
|
|
41
|
-
"@tellescope/types-utilities": "^0.0.
|
|
42
|
-
"@tellescope/utilities": "^0.0.
|
|
36
|
+
"@tellescope/constants": "^0.0.46",
|
|
37
|
+
"@tellescope/react-components": "^0.0.46",
|
|
38
|
+
"@tellescope/sdk": "^0.0.46",
|
|
39
|
+
"@tellescope/types-client": "^0.0.46",
|
|
40
|
+
"@tellescope/types-models": "^0.0.46",
|
|
41
|
+
"@tellescope/types-utilities": "^0.0.46",
|
|
42
|
+
"@tellescope/utilities": "^0.0.46",
|
|
43
43
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
44
44
|
"@typescript-eslint/parser": "^4.33.0",
|
|
45
45
|
"eslint": "^7.32.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"react": "^17.0.2",
|
|
51
51
|
"react-dom": "^17.0.2"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "0e3c8c86f517e6efbb54b12688f8983e5dff3909",
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
}
|
package/src/chat.tsx
CHANGED
|
@@ -243,14 +243,16 @@ const defaultMessagePreviewStyle: CSSProperties = {
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
export interface ConversationPreviewProps {
|
|
246
|
-
onClick?: (room: ChatRoom) => void;
|
|
247
246
|
room: ChatRoom;
|
|
247
|
+
displayInfo: { [index: string]: UserDisplayInfo };
|
|
248
|
+
onClick?: (room: ChatRoom) => void;
|
|
248
249
|
selected?: boolean;
|
|
249
|
-
resolveSenderName?: (room: ChatRoom) => React.ReactNode;
|
|
250
250
|
style?: CSSProperties;
|
|
251
251
|
selectedStyle?: CSSProperties;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
+
type PreviewComponentType = React.JSXElementConstructor<ConversationPreviewProps>
|
|
255
|
+
|
|
254
256
|
interface SidebarInfo {
|
|
255
257
|
selectedRoom?: string;
|
|
256
258
|
onRoomSelect: (roomId: string) => void;
|
|
@@ -258,16 +260,16 @@ interface SidebarInfo {
|
|
|
258
260
|
selectedItemStyle?: CSSProperties;
|
|
259
261
|
itemStyle?: CSSProperties;
|
|
260
262
|
nameStyle?: CSSProperties;
|
|
261
|
-
PreviewComponent?:
|
|
263
|
+
PreviewComponent?: PreviewComponentType,
|
|
262
264
|
previewStyle?: CSSProperties;
|
|
263
265
|
}
|
|
264
266
|
|
|
265
|
-
const ConversationPreview = ({ onClick, selected, room,
|
|
267
|
+
const ConversationPreview = ({ onClick, selected, room, style, selectedStyle }: ConversationPreviewProps) => (
|
|
266
268
|
<Flex flex={1} column onClick={() => !selected && onClick?.(room)}
|
|
267
269
|
style={selected ? (selectedStyle ?? defaultSidebarItemStyleSelected) : (style ?? defaultSidebarItemStyle) }
|
|
268
270
|
>
|
|
269
271
|
<Typography style={defaultMessageNameStyle}>
|
|
270
|
-
|
|
272
|
+
|
|
271
273
|
</Typography>
|
|
272
274
|
|
|
273
275
|
<Typography style={defaultMessagePreviewStyle}>
|
|
@@ -276,56 +278,39 @@ const ConversationPreview = ({ onClick, selected, room, resolveSenderName, style
|
|
|
276
278
|
</Flex>
|
|
277
279
|
)
|
|
278
280
|
|
|
281
|
+
const PreviewWithData = ({ PreviewComponent=ConversationPreview, ...props }: Omit<ConversationPreviewProps, 'displayInfo'> & Pick<SidebarInfo, 'PreviewComponent'>) => {
|
|
282
|
+
const session = useResolvedSession()
|
|
283
|
+
const [displayInfo] = useChatRoomDisplayInfo(props.room.id, session.type)
|
|
284
|
+
|
|
285
|
+
return (
|
|
286
|
+
<PreviewComponent displayInfo={value_is_loaded(displayInfo) ? displayInfo.value : {} }
|
|
287
|
+
{...props}
|
|
288
|
+
/>
|
|
289
|
+
)
|
|
290
|
+
}
|
|
291
|
+
|
|
279
292
|
interface ConversationsProps extends SidebarInfo {
|
|
280
|
-
resolveSenderName: (r: ChatRoom) => string;
|
|
281
293
|
rooms: LoadedData<ChatRoom[]>;
|
|
282
294
|
}
|
|
283
|
-
export const Conversations = ({ rooms, selectedRoom, onRoomSelect,
|
|
284
|
-
<LoadingLinear data={rooms} render={rooms =>
|
|
285
|
-
<List style={style ?? defaultSidebarStyle} items={rooms} onClick={r => onRoomSelect(r.id)} render={(room, { onClick, index }) =>
|
|
286
|
-
<PreviewComponent key={room.id} room={room} onClick={onClick} selected={selectedRoom === room.id}
|
|
287
|
-
resolveSenderName={resolveSenderName ?? (() => room.id)}
|
|
288
|
-
selectedStyle={selectedItemStyle} style={itemStyle}
|
|
289
|
-
/>
|
|
290
|
-
}/>
|
|
291
|
-
}/>
|
|
292
|
-
)
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
export const EndusersConversations = ({ enduserId, ...p } : SidebarInfo & { enduserId: string }) => {
|
|
296
|
-
const [rooms] = useChatRooms('enduser')
|
|
297
|
-
const [displayNames] = useUserDisplayInfo()
|
|
298
|
-
|
|
299
|
-
const resolveChatName = useCallback((r: ChatRoom) => {
|
|
300
|
-
if (r.title) return r.title
|
|
295
|
+
export const Conversations = ({ rooms, selectedRoom, onRoomSelect, PreviewComponent=ConversationPreview, style, selectedItemStyle, itemStyle } : ConversationsProps) => {
|
|
301
296
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
297
|
+
return (
|
|
298
|
+
<LoadingLinear data={rooms} render={rooms =>
|
|
299
|
+
<List style={style ?? defaultSidebarStyle} items={rooms} onClick={r => onRoomSelect(r.id)} render={(room, { onClick, index }) =>
|
|
300
|
+
<PreviewWithData key={room.id} room={room} onClick={onClick} selected={selectedRoom === room.id}
|
|
301
|
+
selectedStyle={selectedItemStyle} style={itemStyle} PreviewComponent={PreviewComponent}
|
|
302
|
+
/>
|
|
303
|
+
}/>
|
|
304
|
+
}/>
|
|
305
|
+
)
|
|
310
306
|
}
|
|
311
307
|
|
|
312
|
-
export const UsersConversations = ({ userId, ...p } : SidebarInfo & { userId: string }) => {
|
|
313
|
-
const [rooms] = useChatRooms('user')
|
|
314
|
-
const [endusers] = useEndusers()
|
|
315
308
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (endusers.status === LoadingStatus.Loaded) {
|
|
320
|
-
const enduser = endusers.value.find(e => e.id === r.enduserIds?.[0])
|
|
321
|
-
if (enduser) return user_display_name(enduser)
|
|
322
|
-
}
|
|
309
|
+
// deprecated while Conversations relies on useResolvedSession
|
|
310
|
+
export const EndusersConversations = ({ enduserId, ...p } : SidebarInfo & { enduserId: string }) => <Conversations {...p} rooms={useChatRooms('enduser')[0]} />
|
|
323
311
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
return <Conversations {...p} rooms={rooms} resolveSenderName={resolveChatName}/>
|
|
328
|
-
}
|
|
312
|
+
// deprecated while Conversations relies on useResolvedSession
|
|
313
|
+
export const UsersConversations = ({ userId, ...p } : SidebarInfo & { userId: string }) => <Conversations {...p} rooms={useChatRooms('user')[0]}/>
|
|
329
314
|
|
|
330
315
|
interface SendMessage_T {
|
|
331
316
|
type: SessionType,
|