reworked site
This commit is contained in:
18
web/app.js
18
web/app.js
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user