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

Feature Request · Show name of user who sent message

Open charltongroves opened this issue 6 years ago • 3 comments

Describe the feature Hey, Some feedback we've gotten from our chat app is that you should be able to see the name of the person sending messages in a group chat.

here is an example in Facebook messenger, notice how 'Matt Jennings' appears above the message group. image

In our app, its pretty much impossible to know who sent the message unless you have memorised everyone Avatar's. image

I looked into doing this using your api and it seems the only way to do it would be to completely re-implement SimpleMessage, which seems like way too much work for something that should be natively included.

Do you think you'd be able to include something like "MessageHeader" or something for the Message component?

charltongroves avatar Feb 24 '20 02:02 charltongroves

Managed to implement this myself


<Channel client={client} channel={channel} Message={MessageWrapper}>
...
...
...
const MessageFooter = (props) => {
  const dontShow = !(
    props.groupStyles?.[0] === 'single' || props.groupStyles?.[0] === 'bottom'
  );
  const showUser =
    props.channel.data.groupChat &&
    props.client.userID !== props.message.user.id;
  return dontShow ? null : (
    <View style={styles.footerWrapper}>
      {showUser && (
        <Text style={styles.footerTextUser}>{`${props.message.user.name.split(
          ' ',
        )[0] || ''} `}</Text>
      )}
      <Text style={styles.footerTextTime}>
        {moment(props.message.created_at).format('h:mma')}
      </Text>
    </View>
  );
};

const MessageWrapper = (props) => (
  <MessageSimple {...props} MessageFooter={MessageFooter} />
);

Results in the name showing up next to the timestamp image

Was still quite a lot of work though for something that should probably be there by default

charltongroves avatar Feb 24 '20 05:02 charltongroves

@charltongroves I am working on similar example on this PR - https://github.com/GetStream/stream-chat-react-native/pull/152 And building the doc for same - https://github.com/GetStream/stream-chat-react-native/blob/vishal/docs-improvement/src/components/docs/examples/index.md

So it can set ready made examples of these use cases. Maybe I will make these components part of repo as well. But its still WIP.

vishalnarkhede avatar Mar 27 '20 11:03 vishalnarkhede

@charltongroves was this implemented or was your suggestion the solution?

The newer library doesn't seem to support this at all.

jetaggart avatar Mar 07 '24 05:03 jetaggart