this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Hide poll button if maxOptions <= 1

It's not a poll if there's only 1 option

+24 -16
+24 -16
src/components/compose.jsx
··· 1219 1219 /> 1220 1220 <Icon icon="attachment" /> 1221 1221 </label>{' '} 1222 - <button 1223 - type="button" 1224 - class="toolbar-button" 1225 - disabled={ 1226 - uiState === 'loading' || !!poll || !!mediaAttachments.length 1227 - } 1228 - onClick={() => { 1229 - setPoll({ 1230 - options: ['', ''], 1231 - expiresIn: 24 * 60 * 60, // 1 day 1232 - multiple: false, 1233 - }); 1234 - }} 1235 - > 1236 - <Icon icon="poll" alt="Add poll" /> 1237 - </button>{' '} 1222 + {/* If maxOptions is not defined or defined and is greater than 1, show poll button */} 1223 + {maxOptions == null || 1224 + (maxOptions > 1 && ( 1225 + <> 1226 + <button 1227 + type="button" 1228 + class="toolbar-button" 1229 + disabled={ 1230 + uiState === 'loading' || 1231 + !!poll || 1232 + !!mediaAttachments.length 1233 + } 1234 + onClick={() => { 1235 + setPoll({ 1236 + options: ['', ''], 1237 + expiresIn: 24 * 60 * 60, // 1 day 1238 + multiple: false, 1239 + }); 1240 + }} 1241 + > 1242 + <Icon icon="poll" alt="Add poll" /> 1243 + </button>{' '} 1244 + </> 1245 + ))} 1238 1246 <button 1239 1247 type="button" 1240 1248 class="toolbar-button"