jevstrudel.git / website / src / jev / press.mjs
1// A 🔥 or 😴 for the section playing: the booth's buttons (JevBooth.jsx)
2// and the MCP's react (tabTools.mjs) press the same. Jev hears it before
3// its next choice (party.mjs's `react`: the room's count in a party, else
4// the booth's own), and every listener's tally counts it for the song as
5// written only (reactions.mjs), so an edited song or an AI's code is heard
6// by Jev in this play but not counted for the song.
7import { nowPlaying, readSongs } from './client.mjs';
8import { react } from './party.mjs';
9import { sectionOf, sendReaction } from './reactions.mjs';
10
11export function pressReaction(booth, segment, kind, editor) {
12  react(booth, segment, kind);
13  const song = readSongs().find((s) => s.id === nowPlaying.get());
14  const section = sectionOf(booth, segment);
15  const counted = Boolean(song && editor?.code === song.code && section);
16  if (counted) sendReaction({ song: song.id, section, reaction: kind });
17  return { section, counted };
18}