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

refactored the code from line 83-93 in the filesrc/messaging/data.js #28

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/messaging/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,17 @@ module.exports = function (Messaging) {
// Add a spacer in between messages with time gaps between them
messages = messages.map((message, index) => {
// Compare timestamps with the previous message, and check if a spacer needs to be added
if (index > 0 && message.timestamp > messages[index - 1].timestamp + Messaging.newMessageCutoff) {
// If it's been 5 minutes, this is a new set of messages
message.newSet = true;
} else if (index > 0 && message.fromuid !== messages[index - 1].fromuid) {
// If the previous message was from the other person, this is also a new set
message.newSet = true;
} else if (index > 0 && messages[index - 1].system) {
message.newSet = true;
} else if (index === 0 || message.toMid) {
message.newSet = true;
// If the previous message was from the other person, this is also a new set
if (index > 0) {
// Also check if the previous message was a system message, in which case we don't add a spacer
// Also check if the previous message was a new set, in which case we don't add a spacer
// Also check if the previous message was a system message, in which case we don't add a spacer
// Also check if the previous message was a new set, in which case we don't add a spacer
if (message.timestamp > messages[index - 1].timestamp + Messaging.newMessageCutoff() ||
message.fromUid !== messages[index - 1].fromUid ||
messages[index - 1].system) {
message.newSet = true;
}
}

return message;
Expand Down
Loading