Browse Source

offline_get_all: do not redownload already cached books

Andrew Dolgov 2 years ago
parent
commit
c63095caf4
1 changed files with 11 additions and 2 deletions
  1. 11 2
      js/index.js

+ 11 - 2
js/index.js

@@ -207,9 +207,18 @@ function offline_get_all() {
 			var dropitem = $(row).find(".offline_dropitem")[0];
 
 			if (bookId) {
-				offline_cache(bookId, function() {
-					mark_offline(dropitem);
+
+				var cacheId = 'epube-book.' + bookId;
+				localforage.getItem(cacheId).then(function(book) {
+
+					if (!book) {
+						offline_cache(bookId, function() {
+							mark_offline(dropitem);
+						});
+					}
+
 				});
+
 			}
 		});
 	}