-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcomponent.tsx
More file actions
55 lines (51 loc) · 1.74 KB
/
Copy pathcomponent.tsx
File metadata and controls
55 lines (51 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Observable } from '@legendapp/state';
import { useSelector } from '@legendapp/state/react';
import { ReactElement } from 'react';
import { AttachedFileItem } from '@open-webui-react-native/mobile/chat/features/attached-file-item';
import { AttachedImageItem } from '@open-webui-react-native/mobile/chat/features/attached-image-item';
import { View } from '@open-webui-react-native/mobile/shared/ui/ui-kit';
import { FileData, ImageData } from '@open-webui-react-native/shared/data-access/common';
interface AttachedFilesListProps {
onDeleteFilePress: (id: string) => void;
attachedFiles: Observable<Array<FileData>>;
onImagePress: (index: number) => void;
onDeleteImagePress: (uri: string) => void;
attachedImages: Observable<Array<ImageData>>;
}
export function AttachedFilesList({
onDeleteFilePress,
attachedFiles,
onImagePress,
onDeleteImagePress,
attachedImages,
}: AttachedFilesListProps): ReactElement | null {
const files = useSelector(attachedFiles);
const images = useSelector(attachedImages);
if (files.length === 0 && images.length === 0) {
return null;
}
return (
<View className='gap-8 mb-[8]'>
{files.flatMap((file) =>
file ? [<AttachedFileItem
key={file.id}
file={file}
onDeleteFilePress={onDeleteFilePress} />] : [],
)}
<View className='gap-8 flex-row flex-wrap'>
{images.flatMap((image, index) =>
image
? [
<AttachedImageItem
key={image.uri}
onImagePress={() => onImagePress(index)}
onDeleteImagePress={onDeleteImagePress}
image={image}
/>,
]
: [],
)}
</View>
</View>
);
}