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