feat: render polls

This commit is contained in:
2023-04-05 16:10:14 +01:00
parent 92dac6a699
commit bbc7e443df
9 changed files with 154 additions and 4 deletions

View File

@ -28,6 +28,7 @@ import useModeration from "Hooks/useModeration";
import { setPinned, setBookmarked } from "State/Login";
import type { RootState } from "State/Store";
import { UserCache } from "Cache/UserCache";
import Poll from "Element/Poll";
import messages from "./messages";
import { EventExt } from "System/EventExt";
@ -270,7 +271,8 @@ export default function Note(props: NoteProps) {
);
}
if (ev.kind !== EventKind.TextNote) {
const canRenderAsTextNote = [EventKind.TextNote, EventKind.Polls];
if (!canRenderAsTextNote.includes(ev.kind)) {
return (
<>
<h4>
@ -300,6 +302,12 @@ export default function Note(props: NoteProps) {
}
}
function pollOptions() {
if (ev.kind !== EventKind.Polls) return;
return <Poll ev={ev} zaps={zaps} />;
}
function content() {
if (!inView) return undefined;
return (
@ -332,6 +340,7 @@ export default function Note(props: NoteProps) {
<div className="body" onClick={e => goToEvent(e, ev, true)}>
{transformBody()}
{translation()}
{pollOptions()}
{options.showReactionsLink && (
<div className="reactions-link" onClick={() => setShowReactions(true)}>
<FormattedMessage {...messages.ReactionsLink} values={{ n: totalReactions }} />