Permalink
Browse files

Commit entry modifications

Currently, we rely on the event entries to modify
the stale edited ones. But when we refresh this
is a lot harder and error-prone.

That's why we just commit the changes and when
event entries and its edited entry happen to be
in the same result set, we just skip the event
entry.
  • Loading branch information...
1 parent 9ae880d commit a2723d4f9dad5524098840e2541a1351f6028ad6 @nb nb committed Jul 23, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 liveblog.php
View
@@ -149,6 +149,7 @@ function ajax_insert_entry() {
self::ajax_check_nonce();
$post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0;
+ $replaces_comment_id = isset( $_POST['replaces'] )? intval( $_POST['replaces'] ) : 0;
if ( ! $post_id )
self::send_error( __( "Sorry, that's an invalid post_id", 'liveblog' ) );
@@ -180,6 +181,14 @@ function ajax_insert_entry() {
self::send_error( __( 'Error posting entry!' ) );
}
+ if ( $replaces_comment_id ) {
+ add_comment_meta( $new_comment_id, WPCOM_Liveblog_Entry::replaces_meta_key, $replaces_comment_id );
+ if ( $_POST['entry_content'] )
+ wp_update_comment( array( 'comment_ID' => $replaces_comment_id, 'comment_content' => $entry_content ) );
+ else
+ wp_delete_comment( $replaces_comment_id );
+ }
+
$entry = WPCOM_Liveblog_Entry::from_comment( get_comment( $new_comment_id ) );
// do not send latest_timestamp, because if we send it the client won't try to get older entries, but since we now send only the inserted

0 comments on commit a2723d4

Please sign in to comment.