|
|
@@ -275,6 +275,19 @@ function showToastNotification(iconType, notificationMessage) {
|
|
|
setTimeout(() => toastElementWrapper.classList.add("toast-animate"), 100);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Navigate to the current page from the top without preserving scroll position.
|
|
|
+ *
|
|
|
+ * Unlike location.reload(), location.replace() does not restore the previous
|
|
|
+ * scroll position. We also clear the hash so the browser fetches the page
|
|
|
+ * instead of treating location.replace() as an in-page jump.
|
|
|
+ */
|
|
|
+function reloadPageAtTop() {
|
|
|
+ const url = new URL(window.location.href);
|
|
|
+ url.hash = "";
|
|
|
+ window.location.replace(url.href);
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Navigate to a specific page.
|
|
|
*
|
|
|
@@ -287,7 +300,7 @@ function goToPage(page, reloadOnFail = false) {
|
|
|
if (element) {
|
|
|
document.location.href = element.href;
|
|
|
} else if (reloadOnFail) {
|
|
|
- window.location.reload();
|
|
|
+ reloadPageAtTop();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -588,7 +601,7 @@ function markPageAsReadAction() {
|
|
|
const showOnlyUnread = element?.dataset.showOnlyUnread || false;
|
|
|
|
|
|
if (showOnlyUnread) {
|
|
|
- window.location.reload();
|
|
|
+ reloadPageAtTop();
|
|
|
} else {
|
|
|
goToPage("next", true);
|
|
|
}
|