Fix age of report not showing when no chat messages

Use a dummy value for now until I get the system to calculate the age
 of the report.
This commit is contained in:
Keir Nellyer 2016-06-29 18:16:26 -04:00
parent a3f4a4c185
commit 1c73d2a793
2 changed files with 9 additions and 24 deletions

View File

@ -39,25 +39,6 @@
return $this->messages;
}
/**
* @return Message
*/
public function getLatestMessage()
{
/** @var Message $latest */
$latest = null;
foreach ($this->messages as $message)
{
if ($latest == null || $latest->getTimestamp()->diff($message->getTimestamp()) > 0) // todo test
{
$latest = $message;
}
}
return $latest;
}
/**
* @return User[]
*/

View File

@ -290,7 +290,10 @@ function parseDateTime($dateTime, $timezone)
*/
function approximateHumanInterval($interval)
{
if ($interval->m > 0)
if ($interval->y > 0)
{
$humanString = $interval->y . ' year' . ($interval->y != 0 ? 's' : '');
} else if ($interval->m > 0)
{
$humanString = $interval->m . ' month' . ($interval->m != 0 ? 's' : '');
}
@ -419,13 +422,14 @@ if ($validId)
$reporterUsernames[count($reporterUsernames)] = $reporter->getUsername();
}
// TODO Calculate time since last report
// TODO actually calculate time
$lastReportTime = new DateTime('1999-01-12');
$age = approximateHumanInterval($lastReportTime->diff(new DateTime('now', $lastReportTime->getTimezone())));
if ($displayAmount == 0): ?>
<span class="black">No chat log available for this report.</span>
<?php else:
// TODO Calculate time since last report
$lastReportTime = $snapshot->getLatestMessage()->getTimestamp();
$age = approximateHumanInterval($lastReportTime->diff(new DateTime('now', $lastReportTime->getTimezone())));
for ($i = 0; $i < $displayAmount; $i++):
$message = $messages[$i];
$typeId = $message->getType();