Просмотр исходного кода

Affichage dynamique des favoris non lus

Corrige https://github.com/marienfressinaud/FreshRSS/issues/222
Il reste toujours une situation curieuse lorsqu'on a fini de lire tous
les favoris non-lus, mais à voir une autre fois
Alexandre Alapetite 12 лет назад
Родитель
Сommit
bdb69080f8
2 измененных файлов с 13 добавлено и 15 удалено
  1. 0 5
      app/models/Entry.php
  2. 13 10
      public/scripts/main.js

+ 0 - 5
app/models/Entry.php

@@ -487,11 +487,6 @@ class EntryDAO extends Model_pdo {
 		return $readUnread;
 	}
 
-	public function countFavorites () {	//Deprecated: use countUnreadReadFavorites() instead
-		$unreadRead = $this->countUnreadReadFavorites ();	//This makes better use of caching
-		return $unreadRead['unread'] + $unreadRead['read'];
-	}
-
 	public function optimizeTable() {
 		$sql = 'OPTIMIZE TABLE ' . $this->prefix . 'entry';
 		$stm = $this->bd->prepare ($sql);

+ 13 - 10
public/scripts/main.js

@@ -72,6 +72,13 @@ function mark_read(active, only_not_read) {
 			elem.setAttribute('data-unread', Math.max(0, feed_unread + inc));
 		}
 
+		//Update unread: favourites
+		if (active.closest('div').hasClass('favorite')) {
+			elem = $('#aside_flux .favorites').children(':first').get(0);
+			feed_unread = elem ? (parseInt(elem.getAttribute('data-unread'), 10) || 0) : 0;
+			elem.setAttribute('data-unread', Math.max(0, feed_unread + inc));
+		}
+
 		//Update unread: title
 		document.title = document.title.replace(/((?: \(\d+\))?)( - .*?)((?: \(\d+\))?)$/, function (m, p1, p2, p3) {
 			return incLabel(p1, inc) + p2 + incLabel(p3, feed_priority > 0 ? inc : 0);
@@ -112,6 +119,12 @@ function mark_favorite(active) {
 				return incLabel(p1, inc);
 			});
 		}
+
+		if (active.closest('div').hasClass('not_read')) {
+			var elem = $('#aside_flux .favorites').children(':first').get(0),
+				feed_unread = elem ? (parseInt(elem.getAttribute('data-unread'), 10) || 0) : 0;
+			elem.setAttribute('data-unread', Math.max(0, feed_unread + inc));
+		}
 	});
 }
 
@@ -193,15 +206,6 @@ function next_entry() {
 	}
 }
 
-/*function init_img() {
-	var maxWidth = $(".flux_content .content").width() / 2;
-	$(".flux_content .content img").each(function () {
-		if ($(this).width() > maxWidth) {
-			$(this).addClass("big");
-		}
-	});
-}*/
-
 function inMarkViewport(flux, box_to_follow, relative_follow) {
 	var top = flux.position().top;
 	if (relative_follow) {
@@ -229,7 +233,6 @@ function init_lazyload() {
 }
 
 function init_posts() {
-	//init_img();	//Alex
 	init_lazyload();
 
 	var box_to_follow = $(window),