Skip to content

Commit

Permalink
Fix unhandeled nullable attachements counter
Browse files Browse the repository at this point in the history
  • Loading branch information
mashirozx committed Feb 13, 2024
1 parent 819ede1 commit 84b5b14
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import { connect } from 'react-redux';
import {connect} from 'react-redux';

import { uploadCompose } from '../../../actions/compose';
import {uploadCompose} from '../../../actions/compose';
import UploadButton from '../components/upload_button';

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')))),
resetFileKey: state.getIn(['compose', 'resetFileKey']),
});
const mapStateToProps = state => {
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']),
};
};

const mapDispatchToProps = dispatch => ({

onSelectFile (files) {
onSelectFile(files) {
dispatch(uploadCompose(files));
},

Expand Down

0 comments on commit 84b5b14

Please sign in to comment.