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

Support date in MM/DD/YY format

Open familywiser1 opened this issue 6 years ago • 5 comments

Describe the bug Channel Preview currently shows date in DD/MM/YY format. unfortunately, this date format does not work for US based users.

Dev environment info (please complete/provide the following information):

  • Package version (stream-chat-react-native/stream-chat-expo): stream-chat-expo
  • react-native or expo version: expo
  • Device/Emulator (android/ios) and OS version: all

To Reproduce Steps to reproduce the behavior: Follow react-native tutorials at https://getstream.io/chat/react-native-chat/tutorial/#custom-preview . I think the problem is at https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/ChannelPreview.js#L89

Expected behavior Allow clients to specify the date format.

familywiser1 avatar Jan 24 '20 19:01 familywiser1

@familywiser1 thanks for brining this up. We will add a props to customize date format!!

vishalnarkhede avatar Jan 27 '20 08:01 vishalnarkhede

@familywiser1 this has been published - v0.6.3

You can use the prop formatLatestMessageDate in ChannelPreviewMessenger component.

Please let us know if it works for you :)

vishalnarkhede avatar Jan 29 '20 16:01 vishalnarkhede

@vishalnarkhede - Sorry, this may be a dumb question but how do I pass props to ChannelPreviewMessenger?

This is how I am using ChannelList

<ChannelList
                filters={filters}
                sort={sort}
                options={options}
 Preview={ChannelPreviewMessenger}/>

familywiser1 avatar Jan 29 '20 20:01 familywiser1

@familywiser1 this has been published - v0.6.3

You can use the prop formatLatestMessageDate in ChannelPreviewMessenger component.

Please let us know if it works for you :)

Hi @vishalnarkhede - Thanks so much for fixing it so quickly. I will really appreciate if you can let me know how to pass props to ChannelPreviewMessenger. This is how I am using ChannelList

<ChannelList
                filters={filters}
                sort={sort}
                options={options}
 Preview={ChannelPreviewMessenger}/>

I am not how to pass custom props to ChannelPreviewMessenger. Any code example or link to documentation would be really helpful

familywiser1 avatar Jan 31 '20 11:01 familywiser1

@familywiser1 Here's what I suggest trying:

<ChannelList
    filters={filters}
    sort={sort}
    options={options}
    Preview={(props) => <ChannelPreviewMessenger
                 formatLatestMessageDate={(date) => moment(date).toISOString()}
                {...props}
               />
    }
/>

type avatar Feb 12 '20 00:02 type