mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-25 12:34:58 +01:00
Fix unhandled nullable attachments limitation counter (#29183)
This commit is contained in:
parent
f89512fbed
commit
b8bd94ca8e
@ -3,10 +3,20 @@ import { connect } from 'react-redux';
|
|||||||
import { uploadCompose } from '../../../actions/compose';
|
import { uploadCompose } from '../../../actions/compose';
|
||||||
import UploadButton from '../components/upload_button';
|
import UploadButton from '../components/upload_button';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => {
|
||||||
disabled: state.getIn(['compose', 'poll']) !== null || state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size + state.getIn(['compose', 'pending_media_attachments']) > 3 || state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')))),
|
const isPoll = state.getIn(['compose', 'poll']) !== null;
|
||||||
|
const isUploading = state.getIn(['compose', 'is_uploading']);
|
||||||
|
const readyAttachmentsSize = state.getIn(['compose', 'media_attachments']).size ?? 0;
|
||||||
|
const pendingAttachmentsSize = state.getIn(['compose', 'pending_media_attachments']).size ?? 0;
|
||||||
|
const attachmentsSize = readyAttachmentsSize + pendingAttachmentsSize;
|
||||||
|
const isOverLimit = attachmentsSize > 3;
|
||||||
|
const hasVideoOrAudio = state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')));
|
||||||
|
|
||||||
|
return {
|
||||||
|
disabled: isPoll || isUploading || isOverLimit || hasVideoOrAudio,
|
||||||
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
||||||
});
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user