Browse Source

Fix issue with mark-all-as-read-button in anonym. mode (#3944)

* fix

* Update p/scripts/main.js

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
maTh 4 years ago
parent
commit
a5410f6d37
2 changed files with 11 additions and 4 deletions
  1. 7 1
      app/views/helpers/pagination.phtml
  2. 4 3
      p/scripts/main.js

+ 7 - 1
app/views/helpers/pagination.phtml

@@ -17,15 +17,19 @@
 	);
 ?>
 
+<?php
+$hasAccess = FreshRSS_Auth::hasAccess();
+if ($url_mark_read && $hasAccess) { ?>
 <form id="mark-read-pagination" method="post">
 <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
+<?php }?>
 <ul class="pagination">
 	<li class="item pager-next">
 	<?php if (FreshRSS_Context::$next_id) { ?>
 		<a id="load_more" href="<?= Minz_Url::display($url_next) ?>">
 			<?= _t('gen.pagination.load_more') ?>
 		</a>
-	<?php } elseif ($url_mark_read && FreshRSS_Auth::hasAccess()) { ?>
+	<?php } elseif ($url_mark_read && $hasAccess) { ?>
 		<button id="bigMarkAsRead"
 			class="as-link <?= FreshRSS_Context::$user_conf->reading_confirm ? 'confirm" disabled="disabled' : '' ?>"
 			form="mark-read-pagination"
@@ -42,4 +46,6 @@
 	<?php } ?>
 	</li>
 </ul>
+<?php if ($url_mark_read && $hasAccess) { ?>
 </form>
+<?php }?>

+ 4 - 3
p/scripts/main.js

@@ -1546,11 +1546,12 @@ function load_more_posts() {
 		formPagination.replaceChild(paginationNew, paginationOld);
 
 		const bigMarkAsRead = document.getElementById('bigMarkAsRead');
-		if (bigMarkAsRead) {
+		const readAll = document.querySelector('#nav_menu_read_all .read_all');
+		if (readAll && bigMarkAsRead && bigMarkAsRead.formAction) {
 			if (context.display_order === 'ASC') {
-				document.querySelector('#nav_menu_read_all .read_all').formAction = bigMarkAsRead.formAction;
+				readAll.formAction = bigMarkAsRead.formAction;
 			} else {
-				bigMarkAsRead.formAction = document.querySelector('#nav_menu_read_all .read_all').formAction;
+				bigMarkAsRead.formAction = readAll.formAction;
 			}
 		}