[bugzilla-gnome-org-extensions] Load draft after inserting old reviews



commit d4782cf4d37d23ac9ee2538a4bced90a25c3321c
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sun Sep 13 00:09:29 2009 -0400

    Load draft after inserting old reviews
    
    To get the ordering of comments right (current review at the end), load the saved
    draft after inserting old reviews.

 js/splinter.js |   42 +++++++++++++++++++++++-------------------
 1 files changed, 23 insertions(+), 19 deletions(-)
---
diff --git a/js/splinter.js b/js/splinter.js
index 8cbcf30..be38a2f 100644
--- a/js/splinter.js
+++ b/js/splinter.js
@@ -412,21 +412,6 @@ var REVIEW_RE = /^\s*review\s+of\s+attachment\s+(\d+)\s*:\s*/i;
 function start(xml) {
     var i;
 
-    if (reviewStorage) {
-        theReview = reviewStorage.loadDraft(theBug, theAttachment, thePatch);
-        if (theReview) {
-            var storedReviews = reviewStorage.listReviews();
-            $("#restored").show();
-            for (i = 0; i < storedReviews.length; i++) {
-                if (storedReviews[i].bugId == theBug.id &&
-                    storedReviews[i].attachmentId == theAttachment.id)
-                    $("#restoredLastModified").text(Utils.formatDate(new 
Date(storedReviews[i].modificationTime)));
-            }
-        }
-    }
-    if (!theReview)
-        theReview = new Review.Review(thePatch);
-
     document.title = "Attachment " + theAttachment.id + " - " + theAttachment.description + " - Patch 
Review";
 
     $("#loading").hide();
@@ -455,10 +440,6 @@ function start(xml) {
     else
         $("#patchIntro").hide();
 
-    $("#myComment")
-        .val(theReview.intro)
-        .keypress(queueSaveDraft);
-
     var numReviewers = 0;
     for (i = 0; i < theBug.comments.length; i++) {
         var comment = theBug.comments[i];
@@ -492,6 +473,29 @@ function start(xml) {
         }
     }
 
+    // We load the saved draft or create a new reeview *after* inserting the existing reviews
+    // so that the ordering comes out right.
+
+    if (reviewStorage) {
+        theReview = reviewStorage.loadDraft(theBug, theAttachment, thePatch);
+        if (theReview) {
+            var storedReviews = reviewStorage.listReviews();
+            $("#restored").show();
+            for (i = 0; i < storedReviews.length; i++) {
+                if (storedReviews[i].bugId == theBug.id &&
+                    storedReviews[i].attachmentId == theAttachment.id)
+                    $("#restoredLastModified").text(Utils.formatDate(new 
Date(storedReviews[i].modificationTime)));
+            }
+        }
+    }
+
+    if (!theReview)
+        theReview = new Review.Review(thePatch);
+
+    $("#myComment")
+        .val(theReview.intro)
+        .keypress(queueSaveDraft);
+
     for (i = 0; i < thePatch.files.length; i++)
         addPatchFile(thePatch.files[i]);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]