Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render single bubble #739

Closed
pergunt opened this issue Feb 1, 2018 · 10 comments
Closed

Render single bubble #739

pergunt opened this issue Feb 1, 2018 · 10 comments
Labels

Comments

@pergunt
Copy link

pergunt commented Feb 1, 2018

I need to show an error of the current message if sending was false cause server error. When I trying to do that all bubbles taking red color instead of las sended message. How to implement style for last sended message (bubble/MessageText) ?

@xcarpentier
Copy link
Collaborator

Please see #640

@pergunt
Copy link
Author

pergunt commented Feb 2, 2018

I saw that and i tried to import buble to single component and render in the root (Chat) component But when i take the server error end give red color for the right bubble - ALL sended bubbles makes red text color. I need only one which not was sent.

@xcarpentier
Copy link
Collaborator

xcarpentier commented Feb 2, 2018 via email

@pergunt
Copy link
Author

pergunt commented Feb 2, 2018

I am not understood that clearly cause i saw keys in currentMessage obj and there is no style or 'color' key. Only text, id, createdAt, {user: _id}. No color

@xcarpentier
Copy link
Collaborator

Do you have position? left or right?

@pergunt
Copy link
Author

pergunt commented Feb 2, 2018

In 'currentMessage' obj - no. Only those keys which I described allow.

@mafiusu
Copy link

mafiusu commented Feb 2, 2018

In the message object you could provide a custom parameter called sent/received. If currentMessage obj has the key sent with false you will render your Bubble accordingly. As @xcarpentier describes you have to add condition to apply your style or not.

@pergunt
Copy link
Author

pergunt commented Feb 6, 2018

code
code 2
bubble
In the message object or in the currentMessage obj? See my code please. Where it was wrong?

@mafiusu
Copy link

mafiusu commented Feb 7, 2018

I will give you an example.

  1. Provide renderBubble prop for the GiftedChat component
    <GiftedChat renderBubble={this.renderBubble} />
  2. Implement renderBubble
    After you import Bubble from the GiftedChat you can return your Bubble component based on the currentMessage like this:
  renderBubble(props) {
    if(!props.currentMessage.sent){
    // if current Message has not been sent, return other Bubble with backgroundColor red for example
      return (
        <Bubble
        wrapperStyle={{
          right: { backgroundColor: 'red' },
        }}
        {...props}
      />
      );
    }
    return (
      // Return your normal Bubble component if message has been sent.
      <Bubble {...props}  />
    );
  }

@stale
Copy link

stale bot commented Feb 12, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Feb 12, 2019
@stale stale bot closed this as completed Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants