Compare commits
2 commits
main
...
feature/po
Author | SHA1 | Date | |
---|---|---|---|
|
9bd21a726c | ||
|
8551eae7cc |
7 changed files with 6 additions and 11 deletions
|
@ -87,7 +87,6 @@ export const COMPOSE_FOCUS = 'COMPOSE_FOCUS';
|
||||||
|
|
||||||
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.' },
|
|
||||||
open: { id: 'compose.published.open', defaultMessage: 'Open' },
|
open: { id: 'compose.published.open', defaultMessage: 'Open' },
|
||||||
published: { id: 'compose.published.body', defaultMessage: 'Post published.' },
|
published: { id: 'compose.published.body', defaultMessage: 'Post published.' },
|
||||||
saved: { id: 'compose.saved.body', defaultMessage: 'Post saved.' },
|
saved: { id: 'compose.saved.body', defaultMessage: 'Post saved.' },
|
||||||
|
@ -321,11 +320,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, f] of Array.from(files).entries()) {
|
for (const [i, f] of Array.from(files).entries()) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { addPoll, removePoll } from '../../../actions/compose';
|
||||||
import PollButton from '../components/poll_button';
|
import PollButton from '../components/poll_button';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
disabled: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size > 0),
|
disabled: state.getIn(['compose', 'is_uploading']),
|
||||||
active: state.getIn(['compose', 'poll']) !== null,
|
active: state.getIn(['compose', 'poll']) !== null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { openModal } from '../../../actions/modal';
|
||||||
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 hasVideoOrAudio = state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')));
|
const hasVideoOrAudio = state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
disabled: isPoll || isUploading || isOverLimit || hasVideoOrAudio,
|
disabled: isUploading || isOverLimit || hasVideoOrAudio,
|
||||||
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -73,6 +73,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||||
},
|
},
|
||||||
|
|
||||||
polls: {
|
polls: {
|
||||||
|
allow_media: true,
|
||||||
max_options: PollValidator::MAX_OPTIONS,
|
max_options: PollValidator::MAX_OPTIONS,
|
||||||
max_characters_per_option: PollValidator::MAX_OPTION_CHARS,
|
max_characters_per_option: PollValidator::MAX_OPTION_CHARS,
|
||||||
min_expiration: PollValidator::MIN_EXPIRATION,
|
min_expiration: PollValidator::MIN_EXPIRATION,
|
||||||
|
|
|
@ -92,6 +92,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
||||||
},
|
},
|
||||||
|
|
||||||
polls: {
|
polls: {
|
||||||
|
allow_media: true,
|
||||||
max_options: PollValidator::MAX_OPTIONS,
|
max_options: PollValidator::MAX_OPTIONS,
|
||||||
max_characters_per_option: PollValidator::MAX_OPTION_CHARS,
|
max_characters_per_option: PollValidator::MAX_OPTION_CHARS,
|
||||||
min_expiration: PollValidator::MIN_EXPIRATION,
|
min_expiration: PollValidator::MIN_EXPIRATION,
|
||||||
|
|
|
@ -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…
Reference in a new issue