Skip to content

Commit

Permalink
Hide poll button if maxOptions <= 1
Browse files Browse the repository at this point in the history
It's not a poll if there's only 1 option
  • Loading branch information
cheeaun committed Apr 18, 2024
1 parent 6ccefae commit 9235d2c
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/components/compose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1219,22 +1219,30 @@ function Compose({
/>
<Icon icon="attachment" />
</label>{' '}
<button
type="button"
class="toolbar-button"
disabled={
uiState === 'loading' || !!poll || !!mediaAttachments.length
}
onClick={() => {
setPoll({
options: ['', ''],
expiresIn: 24 * 60 * 60, // 1 day
multiple: false,
});
}}
>
<Icon icon="poll" alt="Add poll" />
</button>{' '}
{/* If maxOptions is not defined or defined and is greater than 1, show poll button */}
{maxOptions == null ||
(maxOptions > 1 && (
<>
<button
type="button"
class="toolbar-button"
disabled={
uiState === 'loading' ||
!!poll ||
!!mediaAttachments.length
}
onClick={() => {
setPoll({
options: ['', ''],
expiresIn: 24 * 60 * 60, // 1 day
multiple: false,
});
}}
>
<Icon icon="poll" alt="Add poll" />
</button>{' '}
</>
))}
<button
type="button"
class="toolbar-button"
Expand Down

0 comments on commit 9235d2c

Please sign in to comment.