From 6dc6e3a6bde27898239c422a04b6aadb604776ce Mon Sep 17 00:00:00 2001 From: Job Dufitumukiza Date: Thu, 19 Sep 2024 19:46:00 +0300 Subject: [PATCH 1/4] refactored the code from line 83-93 in the filesrc/messaging/data.js --- src/messaging/data.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/messaging/data.js b/src/messaging/data.js index 20568cc3f7..9a07327ff6 100644 --- a/src/messaging/data.js +++ b/src/messaging/data.js @@ -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; From 487c8ec09c383ee36b0d7508b5f1f9e6f4caa713 Mon Sep 17 00:00:00 2001 From: Job Dufitumukiza Date: Thu, 19 Sep 2024 21:07:04 +0300 Subject: [PATCH 2/4] creating a new branch to test --- src/messaging/data.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/messaging/data.js b/src/messaging/data.js index 9a07327ff6..1a8a33c139 100644 --- a/src/messaging/data.js +++ b/src/messaging/data.js @@ -81,17 +81,7 @@ module.exports = function (Messaging) { messages = messages.map((message, index) => { // Compare timestamps with the previous message, and check if a spacer needs to be added // 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; }); From 566df7762c54fdc441773cfe18745c620ad5c7f4 Mon Sep 17 00:00:00 2001 From: Job Dufitumukiza Date: Thu, 19 Sep 2024 21:08:11 +0300 Subject: [PATCH 3/4] refactored the code from line 83-93 in the filesrc/messaging/data.js --- src/messaging/data.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/messaging/data.js b/src/messaging/data.js index 1a8a33c139..9a07327ff6 100644 --- a/src/messaging/data.js +++ b/src/messaging/data.js @@ -81,7 +81,17 @@ module.exports = function (Messaging) { messages = messages.map((message, index) => { // Compare timestamps with the previous message, and check if a spacer needs to be added // 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; }); From 861ba36c6f7a982d1a643777a33a9e4050fbfdc5 Mon Sep 17 00:00:00 2001 From: Job Dufitumukiza Date: Thu, 19 Sep 2024 21:16:32 +0300 Subject: [PATCH 4/4] refactored the code from line 83-93 in the filesrc/messaging/data.js --- src/messaging/data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/messaging/data.js b/src/messaging/data.js index 9a07327ff6..c89776ca11 100644 --- a/src/messaging/data.js +++ b/src/messaging/data.js @@ -86,7 +86,7 @@ module.exports = function (Messaging) { // 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() || + if (message.timestamp > messages[index - 1].timestamp + Messaging.newMessageCutoff || message.fromUid !== messages[index - 1].fromUid || messages[index - 1].system) { message.newSet = true;