Allow posting media alongside polls
This commit is contained in:
parent
570a8c00a2
commit
e797b43a32
5 changed files with 4 additions and 13 deletions
|
@ -88,7 +88,6 @@ export const COMPOSE_SET_STATUS = 'COMPOSE_SET_STATUS';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' },
|
uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' },
|
||||||
uploadErrorPoll: { id: 'upload_error.poll', defaultMessage: 'File upload not allowed with polls.' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ensureComposeIsVisible = (getState, routerHistory) => {
|
export const ensureComposeIsVisible = (getState, routerHistory) => {
|
||||||
|
@ -318,11 +317,6 @@ export function uploadCompose(files, alt = '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getState().getIn(['compose', 'poll'])) {
|
|
||||||
dispatch(showAlert(undefined, messages.uploadErrorPoll));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch(uploadComposeRequest());
|
dispatch(uploadComposeRequest());
|
||||||
|
|
||||||
for (const [i, f] of Array.from(files).entries()) {
|
for (const [i, f] of Array.from(files).entries()) {
|
||||||
|
|
|
@ -134,7 +134,6 @@ class ComposerOptions extends ImmutablePureComponent {
|
||||||
advancedOptions: ImmutablePropTypes.map,
|
advancedOptions: ImmutablePropTypes.map,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
allowMedia: PropTypes.bool,
|
allowMedia: PropTypes.bool,
|
||||||
allowPoll: PropTypes.bool,
|
|
||||||
hasPoll: PropTypes.bool,
|
hasPoll: PropTypes.bool,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
onChangeAdvancedOption: PropTypes.func,
|
onChangeAdvancedOption: PropTypes.func,
|
||||||
|
@ -206,7 +205,6 @@ class ComposerOptions extends ImmutablePureComponent {
|
||||||
contentType,
|
contentType,
|
||||||
disabled,
|
disabled,
|
||||||
allowMedia,
|
allowMedia,
|
||||||
allowPoll,
|
|
||||||
hasPoll,
|
hasPoll,
|
||||||
onChangeAdvancedOption,
|
onChangeAdvancedOption,
|
||||||
onChangeContentType,
|
onChangeContentType,
|
||||||
|
@ -276,7 +274,7 @@ class ComposerOptions extends ImmutablePureComponent {
|
||||||
{!!pollLimits && (
|
{!!pollLimits && (
|
||||||
<IconButton
|
<IconButton
|
||||||
active={hasPoll}
|
active={hasPoll}
|
||||||
disabled={disabled || !allowPoll}
|
disabled={disabled}
|
||||||
icon='tasks'
|
icon='tasks'
|
||||||
inverted
|
inverted
|
||||||
onClick={onTogglePoll}
|
onClick={onTogglePoll}
|
||||||
|
|
|
@ -18,8 +18,7 @@ function mapStateToProps (state) {
|
||||||
acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']).toArray().join(','),
|
acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']).toArray().join(','),
|
||||||
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
||||||
hasPoll: !!poll,
|
hasPoll: !!poll,
|
||||||
allowMedia: !poll && (media ? media.size + pending_media < 4 && !media.some(item => ['video', 'audio'].includes(item.get('type'))) : pending_media < 4),
|
allowMedia: media ? media.size + pending_media < 4 && !media.some(item => ['video', 'audio'].includes(item.get('type'))) : pending_media < 4,
|
||||||
allowPoll: !(media && !!media.size),
|
|
||||||
showContentTypeChoice: state.getIn(['local_settings', 'show_content_type_choice']),
|
showContentTypeChoice: state.getIn(['local_settings', 'show_content_type_choice']),
|
||||||
contentType: state.getIn(['compose', 'content_type']),
|
contentType: state.getIn(['compose', 'content_type']),
|
||||||
};
|
};
|
||||||
|
|
|
@ -146,7 +146,7 @@ class PostStatusService < BaseService
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4 || @options[:poll].present?
|
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4
|
||||||
|
|
||||||
@media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i))
|
@media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i))
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ class UpdateStatusService < BaseService
|
||||||
def validate_media!
|
def validate_media!
|
||||||
return [] if @options[:media_ids].blank? || !@options[:media_ids].is_a?(Enumerable)
|
return [] if @options[:media_ids].blank? || !@options[:media_ids].is_a?(Enumerable)
|
||||||
|
|
||||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4 || @options[:poll].present?
|
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4
|
||||||
|
|
||||||
media_attachments = @status.account.media_attachments.where(status_id: [nil, @status.id]).where(scheduled_status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i)).to_a
|
media_attachments = @status.account.media_attachments.where(status_id: [nil, @status.id]).where(scheduled_status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i)).to_a
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue