summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-02-15 14:57:18 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-02-15 14:57:18 +0100
commit69ce70be35c511921cf0bfe05f21c3ba44c0f17a (patch)
tree8646bcff202a537dd733cab2900f7e3a392eaa1b
parentccc8c415f30a70a160cec6bca0f7cdfc7dc471f4 (diff)
Add locker to mark_favorite action
Similar to c33b13809ef4e1941d3655479db8c5fcf5731013 See #423
-rw-r--r--p/scripts/main.js22
1 files changed, 17 insertions, 5 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index 44517eb6c..39b780bd7 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -1,7 +1,6 @@
"use strict";
var $stream = null,
- isCollapsed = true,
- pending_feed = [];
+ isCollapsed = true;
function is_normal_mode() {
return $stream.hasClass('normal');
@@ -107,6 +106,7 @@ function incUnreadsFeed(article, feed_id, nb) {
return isCurrentView;
}
+var pending_feeds = [];
function mark_read(active, only_not_read) {
if (active.length === 0 ||
(only_not_read === true && !active.hasClass("not_read"))) {
@@ -120,13 +120,13 @@ function mark_read(active, only_not_read) {
var feed_url = active.find(".website>a").attr("href"),
feed_id = feed_url.substr(feed_url.lastIndexOf('f_')),
- index_pending = pending_feed.indexOf(feed_id);
+ index_pending = pending_feeds.indexOf(feed_id);
if (index_pending !== -1) {
return false;
}
- pending_feed.push(feed_id);
+ pending_feeds.push(feed_id);
$.ajax({
type: 'POST',
@@ -146,7 +146,7 @@ function mark_read(active, only_not_read) {
incUnreadsFeed(active, feed_id, inc);
- pending_feed.splice(index_pending, 1);
+ pending_feeds.splice(index_pending, 1);
});
}
@@ -160,6 +160,16 @@ function mark_favorite(active) {
return false;
}
+ var feed_url = active.find(".website>a").attr("href"),
+ feed_id = feed_url.substr(feed_url.lastIndexOf('f_')),
+ index_pending = pending_feeds.indexOf(feed_id);
+
+ if (index_pending !== -1) {
+ return false;
+ }
+
+ pending_feeds.push(feed_id);
+
$.ajax({
type: 'POST',
url: url,
@@ -190,6 +200,8 @@ function mark_favorite(active) {
elem.setAttribute('data-unread', numberFormat(feed_unreads + inc));
}
}
+
+ pending_feeds.splice(index_pending, 1);
});
}