reworked site

This commit is contained in:
2025-11-16 14:11:23 +01:00
parent 898f2e0b58
commit b7a9091183
3 changed files with 71 additions and 19 deletions

View File

@@ -1378,7 +1378,16 @@ function updateTabButtons() {
});
}
function isPostsViewActive() {
const postsView = document.querySelector('[data-view="posts"]');
return Boolean(postsView && postsView.classList.contains('app-view--active'));
}
function updateTabInUrl() {
if (!isPostsViewActive()) {
return;
}
const url = new URL(window.location.href);
if (currentTab === 'pending') {
url.searchParams.set('tab', 'pending');
@@ -1387,7 +1396,8 @@ function updateTabInUrl() {
} else {
url.searchParams.set('tab', 'all');
}
window.history.replaceState({}, document.title, `${url.pathname}?${url.searchParams.toString()}${url.hash}`);
const nextState = { ...(window.history.state || {}), view: 'posts' };
window.history.replaceState(nextState, document.title, `${url.pathname}?${url.searchParams.toString()}${url.hash}`);
}
function getTabKey(tab = currentTab) {
@@ -2770,6 +2780,12 @@ document.querySelectorAll('.tab-btn').forEach(btn => {
});
});
window.addEventListener('app:view-change', (event) => {
if (event && event.detail && event.detail.view === 'posts') {
updateTabInUrl();
}
});
if (manualPostForm) {
manualPostForm.addEventListener('submit', handleManualPostSubmit);
}