[Pkg-mozext-commits] [wot] 202/226: More fixes of tags update process

David Prévot taffit at moszumanska.debian.org
Fri May 1 00:35:51 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 68c27226b5a562fd0b306af1779a9916fe38fe73
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date:   Thu Mar 13 11:30:37 2014 +0200

    More fixes of tags update process
---
 content/api.js             | 10 +++++++++-
 content/ratingwindow.js    |  3 ++-
 content/rw/ratingwindow.js |  4 ++--
 content/wg.js              | 28 +++++++++++++++++-----------
 4 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/content/api.js b/content/api.js
index ec65d51..6e479a6 100644
--- a/content/api.js
+++ b/content/api.js
@@ -658,6 +658,8 @@ var wot_api_reload =
 				}
 			}
 
+			wot_wg.update_tags(true);   // forced to update mytags and mastertags
+
 			wot_core.update();
 			wot_hashtable.remove(WOT_RELOAD_RUNNING);
 		} catch (e) {
@@ -1711,6 +1713,7 @@ var wot_api_tags = {
 				{},
 				function (err) {
 					wot_tools.log("api.get_tags() failed", err);
+					wot_wg.release_lock(method);
 				},
 				function (data) {
 					wot_wg.release_lock(method);
@@ -1733,11 +1736,16 @@ var wot_api_tags = {
 			WOT_SITEAPI_ERRORS.error_codes.NO_ACTION_DEFINED
 		];
 
+		var func = wot_wg['set_' + core_keyword];
+
 		if (fail_errors.indexOf(error_code) < 0 && data.wgtags) {  // check for tags data (WOT Groups)
-			var func = wot_wg['set_'+core_keyword];
 			if (typeof(func) == 'function') {
 				func(wot_api_tags.clean(data.wgtags));
 			}
+		} else if (!data.wgtags) {
+			if (typeof(func) == 'function') {
+				func([]);
+			}
 		}
 
 		wot_wg.enable(data.wg === true);
diff --git a/content/ratingwindow.js b/content/ratingwindow.js
index 68b73d0..efbf042 100644
--- a/content/ratingwindow.js
+++ b/content/ratingwindow.js
@@ -404,7 +404,8 @@ var wot_rw = {
 
 	            case "api_get_tags":
 //		            data.core_keyword , data.method
-		            wot_api_tags.get_tags(data.core_keyword, data.method);
+//		            wot_api_tags.get_tags(data.core_keyword, data.method);
+		            wot_wg.update_tags();
 			        break;
 
 	            case "log":
diff --git a/content/rw/ratingwindow.js b/content/rw/ratingwindow.js
index 5ac526c..d574ffb 100644
--- a/content/rw/ratingwindow.js
+++ b/content/rw/ratingwindow.js
@@ -3031,7 +3031,7 @@ $.extend(wot, { ratingwindow: {
 				$tags = $("#wg-tags"),
 				tagmap = [
 					{ list: mytags },
-					{ list: rw.tags }
+					{ list: rw.tags, group: true }
 				],
 				has_tags = 0,
 				prev = {};
@@ -3051,7 +3051,7 @@ $.extend(wot, { ratingwindow: {
 
 					$tag = $("<li></li>")
 						.addClass("wg-tag")
-						.toggleClass("group", _wg.is_group(tag_value))
+						.toggleClass("group", tagmap[i].group || _wg.is_group(tag_value))
 						.toggleClass("mytag", _wg.is_mytag(tag_value));
 
 					info = _wg.get_info(tag_value);
diff --git a/content/wg.js b/content/wg.js
index b03150d..afc18ec 100644
--- a/content/wg.js
+++ b/content/wg.js
@@ -76,22 +76,28 @@ var wot_wg = {
 		wot_hashtable.set("popular_tags_updated", Date.now());
 	},
 
-	update_tags: function () {
+	update_tags: function (force) {
 		// Checks whether particular tag list is expired or haven't been updated yet, and fetches the list
 
-		var tmap = [
-			{
+		if (!this.is_enabled()) return; // no need to update anything if the WG is not even enabled
+
+		var tmap = [];
+
+		if (wot_crypto.islevel("registered")) {
+			tmap.push({
 				keyword: "mytags",
 				method: "getmytags",
 				time_func: wot_wg.get_mytags_updated,
 				time: wot_wg.MYTAGS_UPD_INTERVAL
-			}, {
-				keyword: "popular_tags",
-				method: "getmastertags",
-				time_func: wot_wg.get_popular_tags_updated,
-				time: wot_wg.POPULARTAGS_UPD_INTERVAL
-			}
-		];
+			});
+		}
+
+		tmap.push({
+			keyword: "popular_tags",
+			method: "getmastertags",
+			time_func: wot_wg.get_popular_tags_updated,
+			time: wot_wg.POPULARTAGS_UPD_INTERVAL
+		});
 
 		for (var i = 0; i < tmap.length; i++) {
 			var obj = tmap[i];
@@ -99,7 +105,7 @@ var wot_wg = {
 			if (!this.lock_api(obj.method)) continue;   // skip the iteration of lock is already acquired
 
 			var last_updated = obj.time_func.apply();
-			if (!last_updated || obj.time + last_updated < Date.now()) {
+			if (force || !last_updated || obj.time + last_updated < Date.now()) {
 				wot_api_tags.get_tags(obj.keyword, obj.method);
 			}
 		}

-- 
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