diff --git a/src/app/components/message/content/PollContent.tsx b/src/app/components/message/content/PollContent.tsx index d2022c057..b0af3b59a 100644 --- a/src/app/components/message/content/PollContent.tsx +++ b/src/app/components/message/content/PollContent.tsx @@ -203,12 +203,12 @@ export function PollContent({ mx.sendEvent(roomId, 'm.poll.response' as any, { 'm.relates_to': { rel_type: 'm.reference', event_id: eventId }, 'm.selections': [answerId], - }); + }).catch(() => undefined); } else { mx.sendEvent(roomId, 'org.matrix.msc3381.poll.response' as any, { 'm.relates_to': { rel_type: 'm.reference', event_id: eventId }, 'org.matrix.msc3381.poll.response': { answers: [answerId] }, - }); + }).catch(() => undefined); } }; diff --git a/src/app/features/room/PollCreator.tsx b/src/app/features/room/PollCreator.tsx index 243dd9f2b..d5e7dbcec 100644 --- a/src/app/features/room/PollCreator.tsx +++ b/src/app/features/room/PollCreator.tsx @@ -13,7 +13,7 @@ export function PollCreator({ roomId, onClose }: PollCreatorProps) { const mx = useMatrixClient(); const [question, setQuestion] = useState(''); const [options, setOptions] = useState(['', '']); - const [maxSelections, setMaxSelections] = useState(1); + const [isMultiple, setIsMultiple] = useState(false); const [submitting, setSubmitting] = useState(false); const [error, setError] = useState(null); @@ -54,7 +54,7 @@ export function PollCreator({ roomId, onClose }: PollCreatorProps) { 'm.poll': { question: { 'm.text': trimmedQuestion }, answers: filledOptions.map((o, i) => ({ 'm.id': `${i}`, 'm.text': o })), - max_selections: maxSelections, + max_selections: isMultiple ? filledOptions.length : 1, kind: 'm.poll.undisclosed', }, body: trimmedQuestion, @@ -196,42 +196,29 @@ export function PollCreator({ roomId, onClose }: PollCreatorProps) {
Selection Type
- - + {(['single', 'multiple'] as const).map((type) => { + const active = type === 'multiple' ? isMultiple : !isMultiple; + return ( + + ); + })}