11import { PermissionsAndroid , Platform } from 'react-native' ;
2+ import mime from 'mime' ;
23
34let CameraRollDependency ;
45
@@ -11,12 +12,12 @@ try {
1112 ) ;
1213}
1314
14- import type { Asset } from 'stream-chat-react-native-core' ;
15+ import type { File } from 'stream-chat-react-native-core' ;
1516
1617import { getLocalAssetUri } from './getLocalAssetUri' ;
1718
1819type ReturnType = {
19- assets : Array < Omit < Asset , 'source' > & { source : 'picker' } > ;
20+ assets : Array < File & { source : 'picker' } > ;
2021 endCursor : string | undefined ;
2122 hasNextPage : boolean ;
2223 iOSLimited : boolean ;
@@ -90,16 +91,25 @@ export const getPhotos = CameraRollDependency
9091 const assets = await Promise . all (
9192 results . edges . map ( async ( edge ) => {
9293 const originalUri = edge . node ?. image ?. uri ;
93- const uri = getLocalAssetUri ? await getLocalAssetUri ( originalUri ) : originalUri ;
94+ const mimeType =
95+ Platform . OS === 'ios'
96+ ? mime . getType ( edge . node . image . filename as string )
97+ : edge . node . type ;
98+ const isImage = mimeType . includes ( 'image' ) ;
99+
100+ // TODO: Review this is needed or not
101+ const uri =
102+ isImage && getLocalAssetUri ? await getLocalAssetUri ( originalUri ) : originalUri ;
103+
94104 return {
95105 ...edge . node . image ,
106+ name : edge . node . image . filename as string ,
96107 duration : edge . node . image . playableDuration * 1000 ,
97108 // since we include filename, fileSize in the query, we can safely assume it will be defined
98- name : edge . node . image . filename as string ,
99- originalUri,
109+ thumb_url : isImage ? undefined : originalUri ,
100110 size : edge . node . image . fileSize as number ,
101- source : 'picker' as const ,
102- type : edge . node . type ,
111+ mimeType ,
112+ type : isImage ? 'image' : 'video' ,
103113 uri,
104114 } ;
105115 } ) ,
0 commit comments