openvibers/openvibe.live Commits

Channels: a name nobody has shows 'No channel called @name' at that address (it flashed a toast and dropped the visitor on the home page while the server said 404) (#192)

OP OpenVibers committed 27 days ago · 053060c185 · 2 files, +15 −7

Changes

ddiff --git a/public/js/app-channel.js b/public/js/app-channel.js
iindex 451f21a7..2183a0d3 100644
---- a/public/js/app-channel.js
++++ b/public/js/app-channel.js
@@@ -877,6 +877,12 @@ async function loadChannelPage(username, managedStreamRef = null, legacySessionI
} catch (e) {
_channelReady();
++ if (e && e.status === 404) {
++ // Nobody has this name: say so at this address (the server answered it 404 too), not a toast and the home page.
++ currentChannelUsername = null;
++ showNotFound({ title: `No channel called @${username}`, message: 'Nobody streams under this name. The link may be mistyped, or the account was renamed or removed.' });
++ return;
++ }
console.error('Channel load error:', e);
toast('Channel not found', 'error');
navigate('/');
ddiff --git a/public/js/app.js b/public/js/app.js
iindex d64ab9f7..6e4579e5 100644
---- a/public/js/app.js
++++ b/public/js/app.js
@@@ -1173,18 +1173,18 @@ function routeFromURL() {
}
}
--/** The page for an address no route knows: say so, and offer the way back in. */
--function showNotFound() {
++/** The page for an address no route knows (or a channel nobody has): say so, and offer the way back in. */
++function showNotFound({ title = 'Page not found', message = 'Nothing lives at this address. The link may be mistyped, or what it pointed to was removed or made private.' } = {}) {
const el = document.getElementById('page-not-found');
-- if (el && !el.firstChild) {
++ if (el) {
const box = document.createElement('div');
box.className = 'content-container';
box.style.cssText = 'text-align:center;padding:12vh 16px';
const h1 = document.createElement('h1');
-- h1.textContent = 'Page not found';
++ h1.textContent = title;
const p = document.createElement('p');
p.className = 'page-subtitle';
-- p.textContent = 'Nothing lives at this address. The link may be mistyped, or what it pointed to was removed or made private.';
++ p.textContent = message;
const links = document.createElement('p');
links.style.cssText = 'display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin-top:20px';
for (const [href, label, cls] of [['/', 'Home', 'btn btn-primary'], ['/content', 'Content', 'btn btn-outline'], ['/moments', 'AI Moments', 'btn btn-outline'], ['/chat', 'Chat', 'btn btn-outline']]) {
@@@ -1194,10 +1194,12 @@ function showNotFound() {
links.appendChild(a);
}
box.append(h1, p, links);
-- el.appendChild(box);
++ el.replaceChildren(box);
}
++ // A page that found out late (a channel nobody has) is still showing: only this one stays.
++ document.querySelectorAll('.page.active').forEach((pg) => { if (pg !== el) pg.classList.remove('active'); });
showPage('not-found');
-- setPageTitle('Page not found');
++ setPageTitle(title);
}
/* ═══════════════════════════════════════════════════════════════════════════