Composer: Disable creating non-anonymous polls in channels (#1760)
This commit is contained in:
parent
bd2d21581d
commit
b1fbc1c4b6
@ -47,6 +47,7 @@ import {
|
||||
isUserId,
|
||||
isChatAdmin,
|
||||
isChatSuperGroup,
|
||||
isChatChannel,
|
||||
} from '../../../modules/helpers';
|
||||
import { formatMediaDuration, formatVoiceRecordDuration, getDayStartAt } from '../../../util/dateFormat';
|
||||
import focusEditableElement from '../../../util/focusEditableElement';
|
||||
@ -121,6 +122,7 @@ type StateProps =
|
||||
draft?: ApiFormattedText;
|
||||
isChatWithBot?: boolean;
|
||||
isChatWithSelf?: boolean;
|
||||
isChannel?: boolean;
|
||||
isRightColumnShown?: boolean;
|
||||
isSelectModeActive?: boolean;
|
||||
isForwarding?: boolean;
|
||||
@ -185,6 +187,7 @@ const Composer: FC<OwnProps & StateProps> = ({
|
||||
connectionState,
|
||||
isChatWithBot,
|
||||
isChatWithSelf,
|
||||
isChannel,
|
||||
isRightColumnShown,
|
||||
isSelectModeActive,
|
||||
isForwarding,
|
||||
@ -868,6 +871,7 @@ const Composer: FC<OwnProps & StateProps> = ({
|
||||
/>
|
||||
<PollModal
|
||||
isOpen={Boolean(isPollModalOpen)}
|
||||
shouldBeAnonimous={isChannel}
|
||||
onClear={closePollModal}
|
||||
onSend={handlePollSend}
|
||||
/>
|
||||
@ -1150,6 +1154,7 @@ export default memo(withGlobal<OwnProps>(
|
||||
chat,
|
||||
isChatWithBot,
|
||||
isChatWithSelf,
|
||||
isChannel: chat ? isChatChannel(chat) : undefined,
|
||||
canScheduleUntilOnline: Boolean(
|
||||
!isChatWithSelf && !isChatWithBot && chat && chatUser
|
||||
&& isUserId(chatId) && selectUserStatus(global, chatId)?.wasOnline,
|
||||
|
||||
@ -19,6 +19,7 @@ import './PollModal.scss';
|
||||
|
||||
export type OwnProps = {
|
||||
isOpen: boolean;
|
||||
shouldBeAnonimous?: boolean;
|
||||
onSend: (pollSummary: ApiNewPoll) => void;
|
||||
onClear: () => void;
|
||||
};
|
||||
@ -29,7 +30,9 @@ const MAX_OPTION_LENGTH = 100;
|
||||
const MAX_QUESTION_LENGTH = 255;
|
||||
const MAX_SOLUTION_LENGTH = 200;
|
||||
|
||||
const PollModal: FC<OwnProps> = ({ isOpen, onSend, onClear }) => {
|
||||
const PollModal: FC<OwnProps> = ({
|
||||
isOpen, shouldBeAnonimous, onSend, onClear,
|
||||
}) => {
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
const questionInputRef = useRef<HTMLInputElement>(null);
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
@ -313,11 +316,13 @@ const PollModal: FC<OwnProps> = ({ isOpen, onSend, onClear }) => {
|
||||
<div className="options-divider" />
|
||||
|
||||
<div className="quiz-mode">
|
||||
<Checkbox
|
||||
label={lang('PollAnonymous')}
|
||||
checked={isAnonymous}
|
||||
onChange={handleIsAnonymousChange}
|
||||
/>
|
||||
{!shouldBeAnonimous && (
|
||||
<Checkbox
|
||||
label={lang('PollAnonymous')}
|
||||
checked={isAnonymous}
|
||||
onChange={handleIsAnonymousChange}
|
||||
/>
|
||||
)}
|
||||
<Checkbox
|
||||
label={lang('PollMultiple')}
|
||||
checked={isMultipleAnswers}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user