stream-chat-react-native icon indicating copy to clipboard operation
stream-chat-react-native copied to clipboard

MessageInputContext uploadNewImage types are wrong

Open GregAtFramework opened this issue 3 years ago • 2 comments

The TypeScript signature for MessageInputContext uploadNewImage has changed, and is now more awkward for developers to use.

It was previously uploadNewImage: (image: Partial<Asset>) => Promise<void>.

It is now uploadNewImage: (image: Asset) => Promise<void>.

In stream-chat-expo 4.3.1 then we could do:

uploadNewImage({
  uri: result.uri, // e.g. a file:/// URL of an image from the gallery
});

However from stream-chat-expo 4.6.0, the TypeScript requires us to provide a full Asset, not just Partial<Asset>.

export declare type Asset = {
    duration: number | null;
    filename: string;
    fileSize: string;
    height: number;
    playableDuration: number | null;
    source: 'camera' | 'picker';
    type: string;
    uri: string;
    width: number;
    id?: string;
    size?: number | string;
};

But from my testing, the API behaves as before, and I can continue to provide just uri. If this is the case, it would be good for the TypeScript signature to reflect this.

The only issue I have found with the above is that I have seen intermittent warnings such as Failed to get size for image: https://dublin.stream-io-cdn.com/1179380/images/2832d372-7667-4e2a-a614-6ab06f8eebcc.4144fd27-9ae1-46ec-a707-5c63ca8c372d.jpg?Key-Pair-Id=.... but this doesn't appear to prevent the functionality working.

I also note that the Stream Javascript API doesn't require any extra metadata, so it would be surprising for the uploadNewImage method to require it.

GregAtFramework avatar Jun 20 '22 10:06 GregAtFramework

@khushal87 @vishalnarkhede can you take a look at this? What's the reason of changing the types? We are having the same issue.

sandergo90 avatar Jul 12 '22 15:07 sandergo90

Hey team! Please add your planning poker estimate with ZenHub @khushal87 @madsroskar @vishalnarkhede

vanGalilea avatar Aug 16 '22 08:08 vanGalilea

:tada: This issue has been resolved in version 5.4.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

vishalnarkhede avatar Oct 21 '22 16:10 vishalnarkhede