fix(categories): enable seamless SPA in-place navigation without page reload (v1.6.1)

This commit is contained in:
Enes Yakıştır
2026-10-18 11:50:14 +03:00
parent 47df0d17e7
commit 253ad7400b
2 changed files with 51 additions and 5 deletions
+49 -3
View File
@@ -3120,6 +3120,36 @@ try {
return 'all'; return 'all';
} }
function navigateCategorySeamless(targetUrl, key) {
if (!targetUrl) return;
try {
var isAll = (key === 'all' || targetUrl === '/videos/browse' || targetUrl === '/');
var intermediateUrl = isAll ? '/videos/browse?all=true' : targetUrl;
// SPA transition via HTML5 History + Angular popstate
history.pushState(null, '', intermediateUrl);
window.dispatchEvent(new PopStateEvent('popstate', { state: null }));
if (isAll) {
// Clean up the URL to /videos/browse after Angular processes the change
setTimeout(function () {
try {
history.replaceState(null, '', '/videos/browse');
} catch (e) {}
}, 350);
}
// Schedule unified engine cycle to ensure DOM consistency
if (typeof scheduleUnifiedCycle === 'function') {
scheduleUnifiedCycle(true);
}
} catch (err) {
console.warn('[YakTube] Seamless navigation fallback:', err);
window.location.href = targetUrl;
}
}
function injectCategoryChipsBar() { function injectCategoryChipsBar() {
var path = (window.location.pathname || '').toLowerCase(); var path = (window.location.pathname || '').toLowerCase();
if ( if (
@@ -3232,14 +3262,30 @@ try {
} }
chip.addEventListener('click', function (e) { chip.addEventListener('click', function (e) {
if (cat.key === activeKey) {
e.preventDefault(); e.preventDefault();
return; if (cat.key === getActiveCategoryKey()) return;
}
announce(cat.label + ' kategorisi seçildi.'); announce(cat.label + ' kategorisi seçildi.');
// Immediate visual and ARIA active state update
var allChips = track.querySelectorAll('.yaktube-category-chip');
allChips.forEach(function (c) {
var isCurrent = (c === chip);
c.classList.toggle('active', isCurrent);
c.setAttribute('aria-selected', isCurrent ? 'true' : 'false');
c.setAttribute('tabindex', isCurrent ? '0' : '-1');
});
// Seamless SPA navigation without page reload (v1.6.1)
navigateCategorySeamless(cat.url, cat.key);
}); });
chip.addEventListener('keydown', function (e) { chip.addEventListener('keydown', function (e) {
if (e.key === ' ' || e.key === 'Spacebar') {
e.preventDefault();
chip.click();
return;
}
if (e.key === 'ArrowRight' || e.key === 'ArrowDown') { if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
e.preventDefault(); e.preventDefault();
var next = chip.nextElementSibling; var next = chip.nextElementSibling;
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "peertube-plugin-yaktube-ondemand", "name": "peertube-plugin-yaktube-ondemand",
"version": "1.6.0", "version": "1.6.1",
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations, Sleep Timer, Touch Gestures, Voice Assistant & A11y Engine for PeerTube", "description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations, Sleep Timer, Touch Gestures, Voice Assistant & A11y Engine for PeerTube",
"main": "main.js", "main": "main.js",
"library": "./main.js", "library": "./main.js",