Browse Source

Improve behavior when mark as read / favorite fail

If the request fails:
- Open a notification to inform user
- Remove pending index from the pending_feeds list

Fix https://github.com/FreshRSS/FreshRSS/issues/751
Marien Fressinaud 11 years ago
parent
commit
14206aca16
4 changed files with 13 additions and 0 deletions
  1. 3 0
      app/i18n/en/gen.php
  2. 3 0
      app/i18n/fr/gen.php
  3. 1 0
      app/views/helpers/javascript_vars.phtml
  4. 6 0
      p/scripts/main.js

+ 3 - 0
app/i18n/en/gen.php

@@ -95,6 +95,9 @@ return array(
 		'category_empty' => 'Empty category',
 		'confirm_action' => 'Are you sure you want to perform this action? It cannot be cancelled!',
 		'confirm_action_feed_cat' => 'Are you sure you want to perform this action? You will lose related favorites and user queries. It cannot be cancelled!',
+		'feedback' => array(
+			'request_failed' => 'A problem happened and the request failed.'
+		),
 		'new_article' => 'There are new available articles, click to refresh the page.',
 		'notif_body_new_articles' => 'There are \\d new articles to read on FreshRSS.',
 		'notif_title_new_articles' => 'FreshRSS: new articles!',

+ 3 - 0
app/i18n/fr/gen.php

@@ -95,6 +95,9 @@ return array(
 		'category_empty' => 'Catégorie vide',
 		'confirm_action' => 'Êtes-vous sûr(e) de vouloir continuer ? Cette action ne peut être annulée !',
 		'confirm_action_feed_cat' => 'Êtes-vous sûr(e) de vouloir continuer ? Vous perdrez les favoris et les filtres associés. Cette action ne peut être annulée !',
+		'feedback' => array(
+			'request_failed' => 'Un problème est survenu et la requête a échoué.'
+		),
 		'new_article' => 'Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.',
 		'notif_body_new_articles' => 'Il y a \\d nouveaux articles à lire sur FreshRSS.',
 		'notif_title_new_articles' => 'FreshRSS : nouveaux articles !',

+ 1 - 0
app/views/helpers/javascript_vars.phtml

@@ -62,6 +62,7 @@ echo 'i18n={',
 	'confirmation_default:"', _t('gen.js.confirm_action'), '",',
 	'notif_title_articles:"', _t('gen.js.notif_title_new_articles'), '",',
 	'notif_body_articles:"', _t('gen.js.notif_body_new_articles'), '",',
+	'notif_request_failed:"', _t('gen.js.feedback.request_failed'), '",',
 	'category_empty:"', _t('gen.js.category_empty'), '"',
 "},\n";
 

+ 6 - 0
p/scripts/main.js

@@ -154,6 +154,9 @@ function mark_read(active, only_not_read) {
 		incUnreadsFeed(active, feed_id, inc);
 		faviconNbUnread();
 
+		pending_feeds.splice(index_pending, 1);
+	}).fail(function (data) {
+		openNotification(i18n.notif_request_failed, 'bad');
 		pending_feeds.splice(index_pending, 1);
 	});
 }
@@ -209,6 +212,9 @@ function mark_favorite(active) {
 			}
 		}
 
+		pending_feeds.splice(index_pending, 1);
+	}).fail(function (data) {
+		openNotification(i18n.notif_request_failed, 'bad');
 		pending_feeds.splice(index_pending, 1);
 	});
 }