Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

Make outgoing/incoming a message property or at least make it documented #411

Closed
romanr opened this issue Jul 21, 2014 · 1 comment
Closed

Comments

@romanr
Copy link

romanr commented Jul 21, 2014

Took me many hours if not days to figure out why all my outgoing bubble messages appeared on the left side of screen as if they were incoming:
image

Finally I discovered that you need to set controller's self.sender to same value as you have in message sender! Then the message will appear as outgoing properly.

the code is in JSQMessagesViewController.m:

- (UICollectionViewCell *)collectionView:(JSQMessagesCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    ///////......

    BOOL isOutgoingMessage = [messageSender isEqualToString:self.sender];

  1. It is not clearly documented and only implied that you will assign sender to same value as message sender
  2. there is no API to set the incoming/outgoing direction implicitly
  3. and on top of that, it is generally a bad style to make above distinction by comparing NSStrings

I think the best way would be is to add parameter to JSQMessage constructor like this:

JSQMessage *m = [[JSQMessage alloc] initWithText:messageText 
sender:sender date:messageDate 
direction:jsqDirectionOutgoing];
@jessesquires
Copy link
Owner

Thanks @romanr - This is already in the works, see #389.

Regarding the design:

The implicit distinction/comparison is actually much cleaner and nicer than having to track/set a separate BOOL value, which was a major shortcoming of v4.0 of this library. With the current design, the view is constructed directly from the model data -- not some arbitrary flag. If you compare the old v4.0 to the current build, you'll see how this is a more modular, flexible, and cleaner design.

However, as you noted - docs need to be better! #389 will be implemented soon! 👍

Closing this issue as a duplicate.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants