diff --git a/src/controller/room.php b/src/controller/room.php index a95b4de..56db23f 100644 --- a/src/controller/room.php +++ b/src/controller/room.php @@ -147,12 +147,15 @@ class Room foreach ($records as $record) { - if ($post = $this->post($namespace, $record['key'], $records)) + if ($post = $this->post($namespace, $record['key'], $records, null, $time)) { - $posts[] = $post; + $posts[$time] = $post; } } + // Sort posts by time + krsort($posts); + // Get subject $subject = null; @@ -187,7 +190,7 @@ class Room ); } - public function post(string $namespace, string $key, array $posts = [], ?string $field = null): ?string + public function post(string $namespace, string $key, array $posts = [], ?string $field = null, ?int &$time = 0): ?string { // Check record exists if (!$record = (array) $this->_kevacoin->kevaGet($namespace, $key)) @@ -271,6 +274,9 @@ class Room } } + // Return timestamp + $time = $matches[1]; + // Build final view and send to response return str_replace( [