openvibers/openvibe.chat Commits

A stream chat row names the channel by its @handle (#492)

OP OpenVibers committed 4 days ago · 6c09b7125a · 2 files, +4 −2

The home's Stream chats rows open /@username but showed a bare display name. Both the app and web variants now show @username. Avatar initials keep the display name. Chat-line authors and the member roster still show display names: they are people, not the channel being named.

Changes

ddiff --git a/server/web/home.js b/server/web/home.js
iindex 04fd2d2..93a2097 100644
---- a/server/web/home.js
++++ b/server/web/home.js
@@@ -128,10 +128,10 @@ const listSection = (id, title, more, rows) => `<section class="oc-home-sec oc-h
function streamsSection(a, app) {
if (!a.streams.length) return '';
if (app) {
-- return listSection('oc-h-streams', 'Stream chats', `<a href="${LIVE}/">Who is live</a>`, a.streams.map((s) => row(`${LIVE}/@${esc(s.username)}`, s.display_name, ui.initials(s.display_name), s.live ? '<span class="oc-badge oc-badge-live">Live</span>' : '',
++ return listSection('oc-h-streams', 'Stream chats', `<a href="${LIVE}/">Who is live</a>`, a.streams.map((s) => row(`${LIVE}/@${esc(s.username)}`, '@' + s.username, ui.initials(s.display_name || s.username), s.live ? '<span class="oc-badge oc-badge-live">Live</span>' : '',
s.live && s.title ? esc(s.title) : `${s.messages ? `${plural(s.messages, 'message', 'messages')} this week` : ''}${s.last ? `${s.messages ? ' · ' : ''}last ${esc(ago(s.last))}` : ''}`)));
}
-- const item = (s) => `<li><a class="oc-stream" href="${LIVE}/@${esc(s.username)}"><span class="oc-stream-name"><strong>${esc(s.display_name)}</strong>${s.live ? ' <span class="oc-badge oc-badge-live">Live now</span>' : ''}</span>
++ const item = (s) => `<li><a class="oc-stream" href="${LIVE}/@${esc(s.username)}"><span class="oc-stream-name"><strong>@${esc(s.username)}</strong>${s.live ? ' <span class="oc-badge oc-badge-live">Live now</span>' : ''}</span>
<span class="oc-muted">${s.live && s.title ? `${esc(s.title)}${s.messages ? ' · ' : ''}` : ''}${s.messages ? `${plural(s.messages, 'message', 'messages')} from ${plural(s.people, 'person', 'people')} this week` : ''}${s.last && !s.live ? ` · last ${esc(ago(s.last))}` : ''}</span></a></li>`;
return `<section class="oc-home-sec" aria-labelledby="oc-h-streams"><div class="oc-home-head"><h2 id="oc-h-streams">Stream chats on OpenVibe.Live</h2><a href="${LIVE}/">Who is live</a></div>
<p class="oc-muted">Every channel on OpenVibe.Live has its own chat, run by OpenVibe.Chat. The busiest this week:</p>
ddiff --git a/test/home-short.test.js b/test/home-short.test.js
iindex ced6339..e1fa5a0 100644
---- a/test/home-short.test.js
++++ b/test/home-short.test.js
@@@ -25,6 +25,8 @@ t('the home is one pick block: a chip per section, the first picked, every secti
const streamer = await db.get("SELECT id FROM ctx_users WHERE username = 'streamer_x'");
await db.run("INSERT INTO ctx_streams (user_id, title, is_live, started_at) VALUES (?, 'Live from the studio', 1, ?)", [streamer.id, stamp]);
const page = await fetch(`${h.base}/`).then((r) => r.text());
++ // A stream row opens the maker's /@username address, so it is named by its @handle.
++ assert.ok(page.includes('>@streamer_x</'), 'the live stream row is named @streamer_x');
const start = page.indexOf('<div class="pick" id="pick-explore">');
assert.ok(start > 0, 'the pick block is on the home');
const block = page.slice(start, page.indexOf('<div class="pick" id="pick-', start + 10) > 0 ? page.indexOf('<div class="pick" id="pick-', start + 10) : start + 60000);