Handle up to 6 attachments per roar.
parent
ea40ae8de7
commit
71302f6dec
|
@ -229,7 +229,7 @@ export function doodleSet(options) {
|
|||
|
||||
export function uploadCompose(files) {
|
||||
return function (dispatch, getState) {
|
||||
const uploadLimit = 4;
|
||||
const uploadLimit = 6;
|
||||
const media = getState().getIn(['compose', 'media_attachments']);
|
||||
const progress = new Array(files.length).fill(0);
|
||||
let total = Array.from(files).reduce((a, v) => a + v.size, 0);
|
||||
|
@ -247,7 +247,7 @@ export function uploadCompose(files) {
|
|||
dispatch(uploadComposeRequest());
|
||||
|
||||
for (const [i, f] of Array.from(files).entries()) {
|
||||
if (media.size + i > 3) break;
|
||||
if (media.size + i > 5) break;
|
||||
|
||||
resizeImage(f).then(file => {
|
||||
const data = new FormData();
|
||||
|
|
|
@ -141,54 +141,12 @@ class Item extends React.PureComponent {
|
|||
const { attachment, index, size, standalone, letterbox, displayWidth, visible } = this.props;
|
||||
|
||||
let width = 50;
|
||||
let height = 100;
|
||||
let top = 'auto';
|
||||
let left = 'auto';
|
||||
let bottom = 'auto';
|
||||
let right = 'auto';
|
||||
let height = 100 / Math.ceil(size/2);
|
||||
|
||||
if (size === 1) {
|
||||
width = 100;
|
||||
}
|
||||
|
||||
if (size === 4 || (size === 3 && index > 0)) {
|
||||
height = 50;
|
||||
}
|
||||
|
||||
if (size === 2) {
|
||||
if (index === 0) {
|
||||
right = '2px';
|
||||
} else {
|
||||
left = '2px';
|
||||
}
|
||||
} else if (size === 3) {
|
||||
if (index === 0) {
|
||||
right = '2px';
|
||||
} else if (index > 0) {
|
||||
left = '2px';
|
||||
}
|
||||
|
||||
if (index === 1) {
|
||||
bottom = '2px';
|
||||
} else if (index > 1) {
|
||||
top = '2px';
|
||||
}
|
||||
} else if (size === 4) {
|
||||
if (index === 0 || index === 2) {
|
||||
right = '2px';
|
||||
}
|
||||
|
||||
if (index === 1 || index === 3) {
|
||||
left = '2px';
|
||||
}
|
||||
|
||||
if (index < 2) {
|
||||
bottom = '2px';
|
||||
} else {
|
||||
top = '2px';
|
||||
}
|
||||
}
|
||||
|
||||
let thumbnail = '';
|
||||
|
||||
if (attachment.get('type') === 'unknown') {
|
||||
|
@ -289,7 +247,7 @@ class Item extends React.PureComponent {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className={classNames('media-gallery__item', { standalone, letterbox })} key={attachment.get('id')} style={{ left: left, top: top, right: right, bottom: bottom, width: `${width}%`, height: `${height}%` }}>
|
||||
<div className={classNames('media-gallery__item', { standalone, letterbox })} key={attachment.get('id')} style={{ width: `${width}%`, height: `${height}%` }}>
|
||||
<canvas width={32} height={32} ref={this.setCanvasRef} className={classNames('media-gallery__preview', { 'media-gallery__preview--hidden': visible && this.state.loaded })} />
|
||||
{visible && thumbnail}
|
||||
</div>
|
||||
|
@ -366,7 +324,7 @@ export default class MediaGallery extends React.PureComponent {
|
|||
render () {
|
||||
const { media, intl, sensitive, letterbox, fullwidth, defaultWidth } = this.props;
|
||||
const { visible } = this.state;
|
||||
const size = media.take(4).size;
|
||||
const size = media.take(6).size;
|
||||
|
||||
const width = this.state.width || defaultWidth;
|
||||
|
||||
|
@ -387,7 +345,7 @@ export default class MediaGallery extends React.PureComponent {
|
|||
if (this.isStandaloneEligible()) {
|
||||
children = <Item standalone onClick={this.handleClick} attachment={media.get(0)} displayWidth={width} visible={visible} />;
|
||||
} else {
|
||||
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} onClick={this.handleClick} attachment={attachment} index={i} size={size} letterbox={letterbox} displayWidth={width} visible={visible} />);
|
||||
children = media.take(6).map((attachment, i) => <Item key={attachment.get('id')} onClick={this.handleClick} attachment={attachment} index={i} size={size} letterbox={letterbox} displayWidth={width} visible={visible} />);
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
|
@ -401,7 +359,7 @@ export default class MediaGallery extends React.PureComponent {
|
|||
}
|
||||
|
||||
let descriptions;
|
||||
descriptions = media.take(4).map(
|
||||
descriptions = media.take(6).map(
|
||||
(attachment, i) => {
|
||||
if (attachment.get('description'))
|
||||
return <p className='media-spoiler__trigger'>Attachment {1+i}: {attachment.get('description')}</p>
|
||||
|
|
|
@ -16,7 +16,7 @@ function mapStateToProps (state) {
|
|||
acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']).toArray().join(','),
|
||||
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
||||
hasPoll: !!poll,
|
||||
allowMedia: !poll && (media ? media.size < 4 && !media.some(item => item.get('type') === 'video') : true),
|
||||
allowMedia: !poll && (media ? media.size < 6 && !media.some(item => item.get('type') === 'video') : true),
|
||||
hasMedia: media && !!media.size,
|
||||
allowPoll: !(media && !!media.size),
|
||||
showContentTypeChoice: state.getIn(['local_settings', 'show_content_type_choice']),
|
||||
|
|
|
@ -93,7 +93,6 @@
|
|||
box-sizing: border-box;
|
||||
display: block;
|
||||
float: left;
|
||||
position: relative;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
visibility: visibility_from_audience,
|
||||
thread: replied_to_status,
|
||||
conversation: conversation_from_uri(@object['conversation']),
|
||||
media_attachment_ids: process_attachments.take(4).map(&:id),
|
||||
media_attachment_ids: process_attachments.take(6).map(&:id),
|
||||
poll: process_poll,
|
||||
}
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ class OStatus::Activity::Creation < OStatus::Activity::Base
|
|||
# Skip if the reblogged status is not public
|
||||
return if cached_reblog && !(cached_reblog.public_visibility? || cached_reblog.unlisted_visibility?)
|
||||
|
||||
media_attachments = save_media.take(4)
|
||||
media_attachments = save_media.take(6)
|
||||
|
||||
ApplicationRecord.transaction do
|
||||
status = Status.create!(
|
||||
|
|
|
@ -103,9 +103,9 @@ class PostStatusService < BaseService
|
|||
def validate_media!
|
||||
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 > 6 || @options[:poll].present?
|
||||
|
||||
@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(6).map(&:to_i))
|
||||
|
||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if @media.size > 1 && @media.find(&:video?)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue