diff --git a/internal/template/templates/common/layout.html b/internal/template/templates/common/layout.html index 9df69984..91cf060e 100644 --- a/internal/template/templates/common/layout.html +++ b/internal/template/templates/common/layout.html @@ -63,7 +63,10 @@ data-webauthn-login-finish-url="{{ route "webauthnLoginFinish" }}" data-webauthn-delete-all-url="{{ route "webauthnDeleteAll" }}" {{ end }} - {{ if .user }}{{ if not .user.KeyboardShortcuts }}data-disable-keyboard-shortcuts="true"{{ end }}{{ end }}> + {{ if .user }} + {{ if not .user.KeyboardShortcuts }}data-disable-keyboard-shortcuts="true"{{ end }} + data-mark-as-read-on-view="{{ if .user.MarkReadOnView }}true{{ else }}false{{ end }}" + {{ end }}> {{ if .user }} {{ t "skip_to_content" }} diff --git a/internal/ui/static/js/app.js b/internal/ui/static/js/app.js index 4add4bd8..32b8bc2d 100644 --- a/internal/ui/static/js/app.js +++ b/internal/ui/static/js/app.js @@ -1268,3 +1268,10 @@ initializeKeyboardShortcuts(); initializeTouchHandler(); initializeClickHandlers(); initializeServiceWorker(); + +// Reload the page if it was restored from the back-forward cache and mark entries as read is enabled. +window.addEventListener("pageshow", (event) => { + if (event.persisted && document.body.dataset.markAsReadOnView === "true") { + location.reload(); + } +});