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

Option to have a single incoming user in group chat #596

Closed
wimbledon opened this issue Nov 4, 2014 · 6 comments
Closed

Option to have a single incoming user in group chat #596

wimbledon opened this issue Nov 4, 2014 · 6 comments

Comments

@wimbledon
Copy link

I would like to have a designated user as the incoming messenger and everybody else including the current sender as the outgoing messenger. Do you think you can make a property in JSQMessagesViewController that expose this option for group chat settings?

David

@jessesquires
Copy link
Owner

Hey @wimbledon - what are you trying to achieve? is this for a right-to-left language?

@jessesquires
Copy link
Owner

This seems like a very rare/specific use case. Not sure I'll add it to the library.

However, please provide more info on what you're trying to achieve when you get a chance! 👍

@wimbledon
Copy link
Author

Thanks for the reply. It's not for right-to-left language.
The use case is for a teacher to have a group chat with all of her students, a host send messages to hostees and etc. The idea emphasize the importance of a designated user as oppose to the current user.

@jessesquires
Copy link
Owner

@wimbledon -- Ahh ok. I think this might be possible within the current framework with few modifications.

The JSQMessagesViewController property senderId is primarily for determining how messages should be displayed in the view — i.e., messages with a matching senderId are displayed on the right, others on the left. Using this, you can have your "designated user" setup to be the "current sender" (i.e., the teacher's senderId matches the view controller's senderId.)

You can add a second property (something like, currentStudentId) in your subclass if you need to also track the "current user".

Then, when you override of this method:

- (void)didPressSendButton:(UIButton *)button
           withMessageText:(NSString *)text
                  senderId:(NSString *)senderId
         senderDisplayName:(NSString *)senderDisplayName
                      date:(NSDate *)date;

You'll need to ignore the senderId and senderDisplayName properties that are passed here. These values are the properties set on the view controller, i.e. your "teacher/designated user". Instead, in this method you'll want to construct your new JSQMessage object with your custom currentStudentId. See the demo project for more details.

If I'm understanding everything correctly, this should work and require minimal effort! 👍

Hope that helps!

@wimbledon
Copy link
Author

Thank you for your help.

The thing is, I want to display the sender/designated user on the LEFT as oppose to on the RIGHT. So, I was hoping for a new property on JSQMessagesViewController to allow me to choose this.

@jessesquires
Copy link
Owner

Ahh I see. For now you'll have to override collectionView: cellForItemAtIndexPath:.

I've opened a feature request issue at #611 for this 👍

(I realize right-to-left language support isn't what you need, but this is all related)

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