feat: sign posted comments with a random team member
Browse filesReplaces the placeholder you author with a random pick from the project roster so the demo feed shows Roberto Mirae Jonathan and Andrés instead of a generic stand-in. The pick happens per post and is reused for the Hub entry so the two views stay consistent.
frontend/src/pages/WatchPage.tsx
CHANGED
|
@@ -18,6 +18,7 @@ import type {
|
|
| 18 |
import {
|
| 19 |
formatPct,
|
| 20 |
newId,
|
|
|
|
| 21 |
randomUsername,
|
| 22 |
relativeTime,
|
| 23 |
toxicityColor,
|
|
@@ -86,9 +87,10 @@ export function WatchPage() {
|
|
| 86 |
setPosting(true);
|
| 87 |
try {
|
| 88 |
const analysis = result ?? (await predict(text, threshold));
|
|
|
|
| 89 |
const item: CommentItem = {
|
| 90 |
id: newId(),
|
| 91 |
-
user:
|
| 92 |
text,
|
| 93 |
time: t.watch.justNow,
|
| 94 |
is_toxic: analysis.is_toxic,
|
|
@@ -98,7 +100,7 @@ export function WatchPage() {
|
|
| 98 |
};
|
| 99 |
setSessionComments((prev) => [...prev, item]);
|
| 100 |
addHubEntry({
|
| 101 |
-
user: `@${
|
| 102 |
snippet: text.slice(0, 45),
|
| 103 |
score: analysis.probability,
|
| 104 |
action: analysis.is_toxic
|
|
|
|
| 18 |
import {
|
| 19 |
formatPct,
|
| 20 |
newId,
|
| 21 |
+
randomTeamMember,
|
| 22 |
randomUsername,
|
| 23 |
relativeTime,
|
| 24 |
toxicityColor,
|
|
|
|
| 87 |
setPosting(true);
|
| 88 |
try {
|
| 89 |
const analysis = result ?? (await predict(text, threshold));
|
| 90 |
+
const author = randomTeamMember();
|
| 91 |
const item: CommentItem = {
|
| 92 |
id: newId(),
|
| 93 |
+
user: author,
|
| 94 |
text,
|
| 95 |
time: t.watch.justNow,
|
| 96 |
is_toxic: analysis.is_toxic,
|
|
|
|
| 100 |
};
|
| 101 |
setSessionComments((prev) => [...prev, item]);
|
| 102 |
addHubEntry({
|
| 103 |
+
user: `@${author}`,
|
| 104 |
snippet: text.slice(0, 45),
|
| 105 |
score: analysis.probability,
|
| 106 |
action: analysis.is_toxic
|
frontend/src/utils/toxicity.ts
CHANGED
|
@@ -13,6 +13,17 @@ export function newId(): string {
|
|
| 13 |
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
| 14 |
}
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
const RTF = new Intl.RelativeTimeFormat("es", { numeric: "auto" });
|
| 17 |
|
| 18 |
const TIME_UNITS: Array<[Intl.RelativeTimeFormatUnit, number]> = [
|
|
|
|
| 13 |
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
| 14 |
}
|
| 15 |
|
| 16 |
+
export const TEAM_MEMBERS = [
|
| 17 |
+
"Roberto Molero",
|
| 18 |
+
"Mirae Kang",
|
| 19 |
+
"Jonathan Brasales",
|
| 20 |
+
"Andrés Torrez",
|
| 21 |
+
] as const;
|
| 22 |
+
|
| 23 |
+
export function randomTeamMember(): string {
|
| 24 |
+
return TEAM_MEMBERS[Math.floor(Math.random() * TEAM_MEMBERS.length)];
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
const RTF = new Intl.RelativeTimeFormat("es", { numeric: "auto" });
|
| 28 |
|
| 29 |
const TIME_UNITS: Array<[Intl.RelativeTimeFormatUnit, number]> = [
|