[Pkg-mozext-commits] [wot] 115/226: Don't fetch comment for undefined target

David Prévot taffit at moszumanska.debian.org
Fri May 1 00:35:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository wot.

commit 92413afd0c62f99cb54294c29614398baa6a4cc6
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date:   Thu Aug 22 16:55:02 2013 +0300

    Don't fetch comment for undefined target
---
 content/api.js             | 35 ++++++++++++++++++++---------------
 content/rw/ratingwindow.js |  2 +-
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/content/api.js b/content/api.js
index 5489cd9..2edef43 100644
--- a/content/api.js
+++ b/content/api.js
@@ -1328,19 +1328,24 @@ var wot_api_comments = {
         var _this = wot_api_comments;
         wdump("wot_api_comments.get(target) " + target);
 
-        _this.call("get",
-            {
-                encryption: true,
-                authentication: true
-            },
-            {
-                target: target
-            },
-            null,   // TODO: handle network errors
-            function (data) {
-                _this.on_get_comment_response(data);
-            }
-        );
+        if (target) {
+            _this.call("get",
+                {
+                    encryption: true,
+                    authentication: true
+                },
+                {
+                    target: target
+                },
+                null,   // TODO: handle network errors
+                function (data) {
+                    _this.on_get_comment_response(data);
+                }
+            );
+        } else {
+            // if target is null, erase the comment info from rating window
+            _this.on_get_comment_response({});
+        }
     },
 
     submit: function (target, comment, comment_id, votes) {
@@ -1513,9 +1518,9 @@ var wot_api_comments = {
         wdump("wot_api_comments.on_get_comment_response(data)" + JSON.stringify(data));
         // check whether error occured or data arrived
         var _this = wot_api_comments,
-            nonce = data.nonce, // to recover target from response
+            nonce = data ? data.nonce : null, // to recover target from response
             target = _this.pull_nonce(nonce),
-            error_code = _this.is_error(data.error);
+            error_code = target ? _this.is_error(data.error) : WOT_COMMENTS.error_codes.COMMENT_NOT_FOUND;
 
         switch (error_code) {
             case WOT_COMMENTS.error_codes.SUCCESS:
diff --git a/content/rw/ratingwindow.js b/content/rw/ratingwindow.js
index 25bf024..3d814e2 100644
--- a/content/rw/ratingwindow.js
+++ b/content/rw/ratingwindow.js
@@ -85,7 +85,7 @@ $.extend(wot, { ratingwindow: {
         }
 
         /* remember previous state */
-        _this.state = $.extend(_this.state, state);
+        _this.state = $.extend(state, _this.state);
     },
 
     setstate: function (component, t) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/wot.git



More information about the Pkg-mozext-commits mailing list