do not duplicatd in progress msg

This commit is contained in:
osaajani 2021-04-13 02:33:30 +02:00
parent 697300b575
commit b9641345a1
2 changed files with 16 additions and 3 deletions

View File

@ -220,8 +220,18 @@ namespace controllers\publics;
if ($messages)
{
$new_limit_date = (new \DateTime($messages[count($messages) - 1]['date']))->getTimestamp(); //Use latest message as the new limit date to search
$response['new_limit_date'] = $new_limit_date;
for ($i = count($messages); $i > 0; $i--)
{
$message = $messages[$i - 1];
if ($message['type'] == 'inprogress')
{
continue;
}
$new_limit_date = (new \DateTime($message['date']))->getTimestamp(); //Use latest not inprogress message as the new limit date to search
$response['new_limit_date'] = $new_limit_date;
break;
}
}
echo json_encode($response);

View File

@ -87,6 +87,9 @@
jQuery('.discussion-container #load-message-spinner').remove();
jQuery('.discussion-container #send-message-spinner').remove();
//We also remove all in-progress messages because they are added again in the new response if not sended yet, and if sended they should not appear in double
jQuery('.discussion-container .message-in-progress-container').remove();
$.each(data.messages, function(key, message) {
<?php if ($_SESSION['user']['settings']['detect_url']) { ?>
@ -146,7 +149,7 @@
break;
case 'inprogress' :
var texte = '' +
'<div class="clearfix message-container">' +
'<div class="clearfix message-container message-in-progress-container">' +
'<div class="discussion-message message-sended">' +
'<div class="message-in-progress-hover"><i class="fa fa-spinner fa-spin"></i></div>' +
'<div class="discussion-message-text">' + message.text + '</div>' +