Change validation to permit polls and media being combined (#39203)
This commit is contained in:
parent
1f1455d1f0
commit
1bbe3872f2
@ -342,11 +342,6 @@ export function uploadCompose(files) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getState().getIn(['compose', 'poll'])) {
|
|
||||||
dispatch(showAlert({ message: messages.uploadErrorPoll }));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch(uploadComposeRequest());
|
dispatch(uploadComposeRequest());
|
||||||
|
|
||||||
for (const [i, file] of Array.from(files).entries()) {
|
for (const [i, file] of Array.from(files).entries()) {
|
||||||
|
|||||||
@ -4,12 +4,10 @@ import { addPoll, removePoll } from '../../../actions/compose';
|
|||||||
import PollButton from '../components/poll_button';
|
import PollButton from '../components/poll_button';
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
const readyAttachmentsSize = state.compose.get('media_attachments').size ?? 0;
|
|
||||||
const hasAttachments = readyAttachmentsSize > 0 || !!state.compose.get('is_uploading');
|
|
||||||
const hasQuote = !!state.compose.get('quoted_status_id');
|
const hasQuote = !!state.compose.get('quoted_status_id');
|
||||||
|
|
||||||
return ({
|
return ({
|
||||||
disabled: hasAttachments || hasQuote,
|
disabled: hasQuote,
|
||||||
active: state.getIn(['compose', 'poll']) !== null,
|
active: state.getIn(['compose', 'poll']) !== null,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import { uploadCompose } from '../../../actions/compose';
|
|||||||
import UploadButton from '../components/upload_button';
|
import UploadButton from '../components/upload_button';
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
const isPoll = state.getIn(['compose', 'poll']) !== null;
|
|
||||||
const isUploading = state.getIn(['compose', 'is_uploading']);
|
const isUploading = state.getIn(['compose', 'is_uploading']);
|
||||||
const readyAttachmentsSize = state.getIn(['compose', 'media_attachments']).size ?? 0;
|
const readyAttachmentsSize = state.getIn(['compose', 'media_attachments']).size ?? 0;
|
||||||
const pendingAttachmentsSize = state.getIn(['compose', 'pending_media_attachments']).size ?? 0;
|
const pendingAttachmentsSize = state.getIn(['compose', 'pending_media_attachments']).size ?? 0;
|
||||||
@ -14,7 +13,7 @@ const mapStateToProps = state => {
|
|||||||
const hasQuote = !!state.compose.get('quoted_status_id');
|
const hasQuote = !!state.compose.get('quoted_status_id');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
disabled: isPoll || isUploading || isOverLimit || hasVideoOrAudio || hasQuote,
|
disabled: isUploading || isOverLimit || hasVideoOrAudio || hasQuote,
|
||||||
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -190,7 +190,7 @@ class PostStatusService < BaseService
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > Status::MEDIA_ATTACHMENTS_LIMIT || @options[:poll].present?
|
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > Status::MEDIA_ATTACHMENTS_LIMIT
|
||||||
|
|
||||||
@media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(Status::MEDIA_ATTACHMENTS_LIMIT).map(&:to_i))
|
@media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(Status::MEDIA_ATTACHMENTS_LIMIT).map(&:to_i))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user