This commit is contained in:
mgabdev
2020-05-02 02:25:55 -04:00
parent e9f01c0b16
commit 196a906cec
62 changed files with 866 additions and 509 deletions

View File

@@ -7,7 +7,6 @@ import {
fetchComposeSuggestions,
selectComposeSuggestion,
changeComposeSpoilerText,
insertEmojiCompose,
uploadCompose,
changeScheduledAt,
} from '../../../actions/compose'
@@ -18,35 +17,66 @@ const mapStateToProps = (state, { replyToId }) => {
const reduxReplyToId = state.getIn(['compose', 'in_reply_to'])
const isMatch = reduxReplyToId || replyToId ? reduxReplyToId === replyToId : true
if (!isMatch) {
return {
isMatch,
edit: null,
text: '',
suggestions: ImmutableList(),
spoiler: false,
spoilerText: '',
privacy: null,
focusDate: null,
caretPosition: null,
preselectDate: null,
isSubmitting: false,
isChangingUpload: false,
isUploading: false,
showSearch: false,
anyMedia: false,
isModalOpen: false,
quoteOfId: null,
scheduledAt: null,
account: state.getIn(['accounts', me]),
hasPoll: false,
selectedGifSrc: null,
reduxReplyToId
}
}
// console.log("isMatch:", isMatch, reduxReplyToId, replyToId, state.getIn(['compose', 'text']))
return {
isMatch,
edit: !isMatch ? null : state.getIn(['compose', 'id']) !== null,
text: !isMatch ? '' : state.getIn(['compose', 'text']),
suggestions: !isMatch ? ImmutableList() : state.getIn(['compose', 'suggestions']),
spoiler: !isMatch ? false : state.getIn(['compose', 'spoiler']),
spoilerText: !isMatch ? '' : state.getIn(['compose', 'spoiler_text']),
privacy: !isMatch ? null : state.getIn(['compose', 'privacy']),
focusDate: !isMatch ? null : state.getIn(['compose', 'focusDate']),
caretPosition: !isMatch ? null : state.getIn(['compose', 'caretPosition']),
preselectDate: !isMatch ? null : state.getIn(['compose', 'preselectDate']),
isSubmitting: !isMatch ? false : state.getIn(['compose', 'is_submitting']),
isChangingUpload: !isMatch ? false : state.getIn(['compose', 'is_changing_upload']),
isUploading: !isMatch ? false : state.getIn(['compose', 'is_uploading']),
showSearch: !isMatch ? false : state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
anyMedia: !isMatch ? false : state.getIn(['compose', 'media_attachments']).size > 0,
isModalOpen: !isMatch ? false : state.getIn(['modal', 'modalType']) === 'COMPOSE',
quoteOfId: !isMatch ? null : state.getIn(['compose', 'quote_of_id']),
scheduledAt: !isMatch ? null : state.getIn(['compose', 'scheduled_at']),
edit: state.getIn(['compose', 'id']) !== null,
text: state.getIn(['compose', 'text']),
suggestions: state.getIn(['compose', 'suggestions']),
spoiler: state.getIn(['compose', 'spoiler']),
spoilerText: state.getIn(['compose', 'spoiler_text']),
privacy: state.getIn(['compose', 'privacy']),
focusDate: state.getIn(['compose', 'focusDate']),
caretPosition: state.getIn(['compose', 'caretPosition']),
preselectDate: state.getIn(['compose', 'preselectDate']),
isSubmitting: state.getIn(['compose', 'is_submitting']),
isChangingUpload: state.getIn(['compose', 'is_changing_upload']),
isUploading: state.getIn(['compose', 'is_uploading']),
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
anyMedia: state.getIn(['compose', 'media_attachments']).size > 0,
isModalOpen: state.getIn(['modal', 'modalType']) === 'COMPOSE',
quoteOfId: state.getIn(['compose', 'quote_of_id']),
scheduledAt: state.getIn(['compose', 'scheduled_at']),
account: state.getIn(['accounts', me]),
hasPoll: !isMatch ? false : state.getIn(['compose', 'poll']),
hasPoll: state.getIn(['compose', 'poll']),
selectedGifSrc: state.getIn(['tenor', 'selectedGif', 'src']),
reduxReplyToId,
}
}
const mapDispatchToProps = (dispatch) => ({
const mapDispatchToProps = (dispatch, { reduxReplyToId, replyToId }) => ({
onChange(text, markdown) {
dispatch(changeCompose(text, markdown))
onChange(text, markdown, newReplyToId) {
console.log("text:", text, newReplyToId, replyToId, reduxReplyToId)
dispatch(changeCompose(text, markdown, newReplyToId))
},
onSubmit(group, replyToId) {
@@ -73,10 +103,6 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(uploadCompose(files))
},
onPickEmoji(position, data, needsSpace) {
dispatch(insertEmojiCompose(position, data, needsSpace))
},
setScheduledAt(date) {
dispatch(changeScheduledAt(date))
},