     update_entry_state_path = $(this).attr "data-entry-state-update-path"
     entry_id = $(this).attr "data-unread-entry-id"
 
-    mark_entry_as_unread entry_id
+    # Function to handle result returned by the server
+    entry_unread_result = (data, status, xhr) ->
+      mark_entry_as_unread entry_id
+      update_unread_counts data
+      
     $.post(update_entry_state_path,
       {_method:"put", entry_ids: [entry_id], state: "unread"},
-        update_entry_state_result, "json")
+      entry_unread_result, "json")
           .fail ->
             Feedbunch.alertTimedShowHide $("#problem-entry-state-change")
 

  #-------------------------------------------------------
  # Function to handle result returned by the server
  #-------------------------------------------------------
  update_entry_state_result = (data, status, xhr) ->
    Feedbunch.update_folder_entry_count "all", data["folder_all"]["sidebar_read_all"]

    if data["feeds"]

      entries = []
      $("[data-entry-id]").each ->
        entry_id = $(this).attr "data-entry-id"
        entries.push entry_id

      # Function to handle result returned by the server
      all_read_result = (data, status, xhr) ->
        for id in entries
          mark_entry_as_read id
        update_unread_counts data

      $.post(update_entry_state_path,
        {_method:"put", entry_ids: entries, state: "read"},
        all_read_result, "json")
          .fail ->
            Feedbunch.alertTimedShowHide $("#problem-entry-state-change")

