2019-04-22 01:31:26 +09:00
|
|
|
import { connect } from 'react-redux';
|
2023-05-28 23:38:10 +09:00
|
|
|
|
2019-04-22 01:31:26 +09:00
|
|
|
import {
|
|
|
|
changeComposeAdvancedOption,
|
2019-05-20 17:05:11 +09:00
|
|
|
changeComposeContentType,
|
|
|
|
addPoll,
|
|
|
|
removePoll,
|
2019-04-22 01:31:26 +09:00
|
|
|
} from 'flavours/glitch/actions/compose';
|
2023-06-06 14:23:12 +09:00
|
|
|
import { openModal, closeModal } from 'flavours/glitch/actions/modal';
|
2019-04-22 01:31:26 +09:00
|
|
|
|
2023-05-28 23:38:10 +09:00
|
|
|
import Options from '../components/options';
|
|
|
|
|
2019-04-22 01:31:26 +09:00
|
|
|
function mapStateToProps (state) {
|
|
|
|
const poll = state.getIn(['compose', 'poll']);
|
|
|
|
const media = state.getIn(['compose', 'media_attachments']);
|
2019-11-07 16:07:03 +09:00
|
|
|
const pending_media = state.getIn(['compose', 'pending_media_attachments']);
|
2019-04-22 01:31:26 +09:00
|
|
|
return {
|
|
|
|
acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']).toArray().join(','),
|
|
|
|
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
|
|
|
hasPoll: !!poll,
|
2019-11-07 16:07:03 +09:00
|
|
|
allowMedia: !poll && (media ? media.size + pending_media < 4 && !media.some(item => ['video', 'audio'].includes(item.get('type'))) : pending_media < 4),
|
2019-04-22 01:31:26 +09:00
|
|
|
allowPoll: !(media && !!media.size),
|
2019-05-13 04:55:44 +09:00
|
|
|
showContentTypeChoice: state.getIn(['local_settings', 'show_content_type_choice']),
|
2019-05-20 17:05:11 +09:00
|
|
|
contentType: state.getIn(['compose', 'content_type']),
|
2019-04-22 01:31:26 +09:00
|
|
|
};
|
2023-02-04 04:52:07 +09:00
|
|
|
}
|
2019-04-22 01:31:26 +09:00
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
|
|
|
onChangeAdvancedOption(option, value) {
|
|
|
|
dispatch(changeComposeAdvancedOption(option, value));
|
|
|
|
},
|
|
|
|
|
2019-05-20 17:05:11 +09:00
|
|
|
onChangeContentType(value) {
|
|
|
|
dispatch(changeComposeContentType(value));
|
|
|
|
},
|
|
|
|
|
2019-04-22 01:31:26 +09:00
|
|
|
onTogglePoll() {
|
|
|
|
dispatch((_, getState) => {
|
|
|
|
if (getState().getIn(['compose', 'poll'])) {
|
|
|
|
dispatch(removePoll());
|
|
|
|
} else {
|
|
|
|
dispatch(addPoll());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onDoodleOpen() {
|
2023-05-25 22:42:37 +09:00
|
|
|
dispatch(openModal({
|
|
|
|
modalType: 'DOODLE',
|
|
|
|
modalProps: { noEsc: true, noClose: true },
|
|
|
|
}));
|
2019-04-22 01:31:26 +09:00
|
|
|
},
|
2021-01-19 01:05:19 +09:00
|
|
|
|
2022-04-17 09:04:23 +09:00
|
|
|
onEmbedTenor() {
|
2023-06-06 14:23:12 +09:00
|
|
|
dispatch(openModal({
|
|
|
|
modalType: 'TENOR',
|
|
|
|
modalProps: { noEsc: true },
|
|
|
|
}));
|
2021-01-19 01:05:19 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
onModalClose() {
|
2023-06-06 14:23:12 +09:00
|
|
|
dispatch(closeModal({
|
|
|
|
modalType: undefined,
|
|
|
|
ignoreFocus: false,
|
|
|
|
}));
|
2021-01-19 01:05:19 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
onModalOpen(props) {
|
2023-06-06 14:23:12 +09:00
|
|
|
dispatch(openModal({ modalType: 'ACTIONS', modalProps: props }));
|
2021-01-19 01:05:19 +09:00
|
|
|
},
|
2019-04-22 01:31:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Options);
|