← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/fix-draft-deletion into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/fix-draft-deletion into lp:launchpad.

Commit message:
Fix inline comment draft Delete link to actually flush the change to the server.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/fix-draft-deletion/+merge/221362

The Delete link on inline comments removes the comment from the UI and the JS dict, but doesn't actually flush the change to the server. So refreshing the page revives the draft from the dead.

This fixes that by factoring out the flush as well.
-- 
https://code.launchpad.net/~wgrant/launchpad/fix-draft-deletion/+merge/221362
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/fix-draft-deletion into lp:launchpad.
=== modified file 'lib/lp/code/javascript/branchmergeproposal.inlinecomments.js'
--- lib/lp/code/javascript/branchmergeproposal.inlinecomments.js	2014-05-28 21:03:14 +0000
+++ lib/lp/code/javascript/branchmergeproposal.inlinecomments.js	2014-05-29 11:41:34 +0000
@@ -38,7 +38,23 @@
     delete namespace.inlinecomments[line_number];
     draft_div.remove(true);
     namespace.cleanup_empty_comment_containers();
-}
+};
+
+namespace.flush_drafts_to_server = function() {
+    var config = {
+        on: {
+            success: function () {
+                Y.fire('inlinecomment.UPDATED');
+            }
+        },
+        parameters: {
+            previewdiff_id: namespace.current_previewdiff_id,
+            comments: namespace.inlinecomments
+        }
+    };
+    namespace.lp_client.named_post(
+        LP.cache.context.self_link, 'saveDraftInlineComment', config);
+};
 
 namespace.add_doubleclick_handler = function() {
     var handling_request = false;
@@ -66,19 +82,7 @@
             if (this.get('value') === '') {
                 namespace.delete_draft(draft_div);
             }
-            var config = {
-                on: {
-                    success: function () {
-                        Y.fire('inlinecomment.UPDATED');
-                    }
-                },
-                parameters: {
-                    previewdiff_id: namespace.current_previewdiff_id,
-                    comments: namespace.inlinecomments
-                }
-            };
-            namespace.lp_client.named_post(
-                LP.cache.context.self_link, 'saveDraftInlineComment', config);
+            namespace.flush_drafts_to_server();
             handling_request = false;
             draft_div.one('.boardCommentFooter').show();
         });
@@ -99,6 +103,7 @@
         var line_number = namespace.find_line_number(e.currentTarget);
         var draft_div = Y.one('#comments-diff-line-' + line_number + ' .draft');
         namespace.delete_draft(draft_div);
+        namespace.flush_drafts_to_server();
     };
 
     // The editor can be invoked by double-clicking a diff line or


Follow ups