Let streamers set how long messages stay on screen
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 29s

Adds display_duration_seconds to the streamers table (default 10s,
with an idempotent migration for existing rows), a dashboard control
to change it, and wires the value through to the overlay via the
display_message payload instead of a hardcoded 10s.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-07-01 16:56:49 +00:00
parent fab55cde1d
commit f4d023c695
4 changed files with 87 additions and 4 deletions

View file

@ -13,6 +13,7 @@ const {
getOrCreateStreamerByGoogle,
getViewerName,
setViewerName,
updateDisplayDuration,
} = require('./db');
const PORT = process.env.PORT || 3000;
@ -116,9 +117,28 @@ app.get('/api/dashboard', requireAuth, (req, res) => {
overlayUrl: `${origin}/overlay/${streamer.overlay_token}`,
senderUrl: `${origin}/s/${streamer.sender_token}`,
ttsVoice: streamer.tts_voice,
displayDurationSeconds: streamer.display_duration_seconds,
});
});
app.post('/api/settings', requireAuth, (req, res) => {
const user = req.session.user;
const streamer = getOrCreateStreamerByGoogle({
googleId: user.id,
email: user.email,
name: user.name,
picture: user.picture,
});
const seconds = Number(req.body.displayDurationSeconds);
if (!Number.isInteger(seconds) || seconds < 1 || seconds > 120) {
return res.status(400).json({ error: 'displayDurationSeconds must be an integer between 1 and 120' });
}
updateDisplayDuration(streamer.id, seconds);
res.json({ displayDurationSeconds: seconds });
});
app.get('/api/viewer-name', requireAuth, (req, res) => {
const streamer = findStreamerBySenderToken(req.query.token);
if (!streamer) {
@ -208,6 +228,7 @@ io.on('connection', (socket) => {
text: message,
from: displayName,
at: Date.now(),
durationMs: (streamer.display_duration_seconds || 10) * 1000,
});
// Voice is generated after the fact so the text shows up immediately