简体   繁体   中英

Meteor.js: Doing message dependency like most of chat nowadays

What is the best way to do a message dependency in chat where the next message will not show the image of the user if the previous message was sent by the same user? I tried my best doing it in the client where I get all the messages, then loop it before returning it to the client. But sometimes get mixed up.

You could include a field called clientCreateDate or something, where you save the moment the message was submitted on the client. Then display all messages with the appropriate sort. If the prior message was sent by the same user hide the avatar with a class.

This might create instances where another users' message appears earlier in the list than one you just sent, but beyond that you'd always know which message was created first, regardless of when it hit the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM