No need to check for duplicates as they should now be deleted on update.
rodzic
2e3968c8f0
commit
37368caf72
26
index.php
26
index.php
|
@ -538,32 +538,18 @@ HTML;
|
|||
$message_files = array_slice( $message_files, 0, 1000 );
|
||||
|
||||
// Loop through the messages:
|
||||
// Remove any which have been updated.
|
||||
// Ensure messages are in the right order.
|
||||
$messages_ordered = [];
|
||||
$messages_ids = [];
|
||||
foreach ( $message_files as $message_file ) {
|
||||
// Get the contents of the JSON
|
||||
$message = json_decode( file_get_contents( $message_file ), true );
|
||||
// Split the filename
|
||||
$file_parts = explode(".", $message_file );
|
||||
$type = $file_parts[1];
|
||||
|
||||
// Ignore any messages which aren't for display
|
||||
$type = $message["type"];
|
||||
if ( "Undo" == $type ) { continue; }
|
||||
if ( "Undo" == $type || "Delete" == $type ) { continue; }
|
||||
|
||||
// Get the ID
|
||||
if ( isset( $message["object"]["id"] ) ) {
|
||||
$id = $message["object"]["id"];
|
||||
} else if ( isset( $message["id"] ) ) {
|
||||
$id = $message["id"];
|
||||
}
|
||||
|
||||
// Has this message ID already been seen?
|
||||
// If so, it's an older update. Skip displaying it
|
||||
if ( !in_array( $id, $messages_ids ) ) {
|
||||
$messages_ids[] = $id;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
// Get the contents of the JSON
|
||||
$message = json_decode( file_get_contents( $message_file ), true );
|
||||
|
||||
// Sometimes messages are received out of order.
|
||||
// This sorts them by their published time or, if there is none, the received time.
|
||||
|
|
Ładowanie…
Reference in New Issue