jeudi 28 septembre 2017

design pattern for masking group of objects as one

I'm working on a simple messaging app using Django. here is a problem I encountered.
I want users to be able to send message to a group of other users. I also want to show the last sent and received messages for each user.
the problem is when you send out a message to a lot of people. your messages Interface will be filled with the same message (one for each receiver).
what I want to do is have the same UI as group messaging in smartphones meaning all the messages in a group message will be shown as one unless someone answers the message in which case a new conversation will be displayed for that user. I don't want to create a new model (class) for group messages and it would be inefficient to manage this in front end level. is there any design pattern that helps me do this? how can I do this without iterating over all the messages and finding the ones that belong to the same group? thanks in advance.

what I have now:

  • message for person 1: hi
  • message for person 2: hi
  • message for person 3: hi
  • message for person 4: hi
  • message for person 5: hi | message from person 5: hello
  • message for person 6: hi

what I want:

  • message for person 1,2,3,4,6: hi
  • message for person 5: hi | message from person 5: hello

Aucun commentaire:

Enregistrer un commentaire