Refactor modal settings
This commit is contained in:
parent
cafa014018
commit
500165c478
6 changed files with 102 additions and 81 deletions
|
@ -13,7 +13,6 @@ import {
|
||||||
} from '../actions/accounts';
|
} from '../actions/accounts';
|
||||||
import { openModal } from '../actions/modal';
|
import { openModal } from '../actions/modal';
|
||||||
import { initMuteModal } from '../actions/mutes';
|
import { initMuteModal } from '../actions/mutes';
|
||||||
import { unfollowModal } from '../initial_state';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
|
unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
|
||||||
|
@ -32,19 +31,22 @@ const makeMapStateToProps = () => {
|
||||||
const mapDispatchToProps = (dispatch, { intl }) => ({
|
const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
|
|
||||||
onFollow(account) {
|
onFollow(account) {
|
||||||
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
dispatch((_, getState) => {
|
||||||
if (unfollowModal) {
|
const unfollowModal = getState().getIn(['settings', 'unfollowModal']);
|
||||||
dispatch(openModal('CONFIRM', {
|
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
||||||
message: <FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
|
if (unfollowModal) {
|
||||||
confirm: intl.formatMessage(messages.unfollowConfirm),
|
dispatch(openModal('CONFIRM', {
|
||||||
onConfirm: () => dispatch(unfollowAccount(account.get('id'))),
|
message: <FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
|
||||||
}));
|
confirm: intl.formatMessage(messages.unfollowConfirm),
|
||||||
|
onConfirm: () => dispatch(unfollowAccount(account.get('id'))),
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
dispatch(unfollowAccount(account.get('id')));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dispatch(unfollowAccount(account.get('id')));
|
dispatch(followAccount(account.get('id')));
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
dispatch(followAccount(account.get('id')));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onBlock(account) {
|
onBlock(account) {
|
||||||
|
|
|
@ -27,7 +27,6 @@ import { initMuteModal } from '../actions/mutes';
|
||||||
import { initReport } from '../actions/reports';
|
import { initReport } from '../actions/reports';
|
||||||
import { openModal } from '../actions/modal';
|
import { openModal } from '../actions/modal';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import { boostModal, deleteModal } from '../initial_state';
|
|
||||||
import { showAlertForError } from '../actions/alerts';
|
import { showAlertForError } from '../actions/alerts';
|
||||||
import {
|
import {
|
||||||
createRemovedAccount,
|
createRemovedAccount,
|
||||||
|
@ -81,11 +80,14 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
},
|
},
|
||||||
|
|
||||||
onReblog(status, e) {
|
onReblog(status, e) {
|
||||||
if (e.shiftKey || !boostModal) {
|
dispatch((_, getState) => {
|
||||||
this.onModalReblog(status);
|
const boostModal = getState().getIn(['settings', 'boostModal']);
|
||||||
} else {
|
if (e.shiftKey || !boostModal) {
|
||||||
dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
|
this.onModalReblog(status);
|
||||||
}
|
} else {
|
||||||
|
dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onFavourite(status) {
|
onFavourite(status) {
|
||||||
|
@ -112,15 +114,18 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
},
|
},
|
||||||
|
|
||||||
onDelete(status, history, withRedraft = false) {
|
onDelete(status, history, withRedraft = false) {
|
||||||
if (!deleteModal) {
|
dispatch((_, getState) => {
|
||||||
dispatch(deleteStatus(status.get('id'), history, withRedraft));
|
const deleteModal = getState().getIn(['settings', 'deleteModal']);
|
||||||
} else {
|
if (!deleteModal) {
|
||||||
dispatch(openModal('CONFIRM', {
|
dispatch(deleteStatus(status.get('id'), history, withRedraft));
|
||||||
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
|
} else {
|
||||||
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
|
dispatch(openModal('CONFIRM', {
|
||||||
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)),
|
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
|
||||||
}));
|
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
|
||||||
}
|
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onDirect(account, router) {
|
onDirect(account, router) {
|
||||||
|
|
|
@ -20,7 +20,6 @@ import { initReport } from '../../../actions/reports';
|
||||||
import { openModal } from '../../../actions/modal';
|
import { openModal } from '../../../actions/modal';
|
||||||
import { blockDomain, unblockDomain } from '../../../actions/domain_blocks';
|
import { blockDomain, unblockDomain } from '../../../actions/domain_blocks';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import { unfollowModal } from '../../../initial_state';
|
|
||||||
import { List as ImmutableList } from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -45,19 +44,22 @@ const makeMapStateToProps = () => {
|
||||||
const mapDispatchToProps = (dispatch, { intl }) => ({
|
const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
|
|
||||||
onFollow(account) {
|
onFollow(account) {
|
||||||
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
dispatch((_, getState) => {
|
||||||
if (unfollowModal) {
|
const unfollowModal = getState().getIn(['settings', 'unfollowModal']);
|
||||||
dispatch(openModal('CONFIRM', {
|
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
||||||
message: <FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
|
if (unfollowModal) {
|
||||||
confirm: intl.formatMessage(messages.unfollowConfirm),
|
dispatch(openModal('CONFIRM', {
|
||||||
onConfirm: () => dispatch(unfollowAccount(account.get('id'))),
|
message: <FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
|
||||||
}));
|
confirm: intl.formatMessage(messages.unfollowConfirm),
|
||||||
|
onConfirm: () => dispatch(unfollowAccount(account.get('id'))),
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
dispatch(unfollowAccount(account.get('id')));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dispatch(unfollowAccount(account.get('id')));
|
dispatch(followAccount(account.get('id')));
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
dispatch(followAccount(account.get('id')));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onBlock(account) {
|
onBlock(account) {
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
hideStatus,
|
hideStatus,
|
||||||
revealStatus,
|
revealStatus,
|
||||||
} from '../../../actions/statuses';
|
} from '../../../actions/statuses';
|
||||||
import { boostModal } from '../../../initial_state';
|
|
||||||
|
|
||||||
const makeMapStateToProps = () => {
|
const makeMapStateToProps = () => {
|
||||||
const getNotification = makeGetNotification();
|
const getNotification = makeGetNotification();
|
||||||
|
@ -40,15 +39,18 @@ const mapDispatchToProps = dispatch => ({
|
||||||
},
|
},
|
||||||
|
|
||||||
onReblog(status, e) {
|
onReblog(status, e) {
|
||||||
if (status.get('reblogged')) {
|
dispatch((_, getState) => {
|
||||||
dispatch(unreblog(status));
|
const boostModal = getState().getIn(['settings', 'boostModal']);
|
||||||
} else {
|
if (status.get('reblogged')) {
|
||||||
if (e.shiftKey || !boostModal) {
|
dispatch(unreblog(status));
|
||||||
this.onModalReblog(status);
|
|
||||||
} else {
|
} else {
|
||||||
dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
|
if (e.shiftKey || !boostModal) {
|
||||||
|
this.onModalReblog(status);
|
||||||
|
} else {
|
||||||
|
dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onFavourite(status) {
|
onFavourite(status) {
|
||||||
|
|
|
@ -27,7 +27,6 @@ import { initMuteModal } from '../../../actions/mutes';
|
||||||
import { initReport } from '../../../actions/reports';
|
import { initReport } from '../../../actions/reports';
|
||||||
import { openModal } from '../../../actions/modal';
|
import { openModal } from '../../../actions/modal';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import { boostModal, deleteModal } from '../../../initial_state';
|
|
||||||
import { showAlertForError } from '../../../actions/alerts';
|
import { showAlertForError } from '../../../actions/alerts';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -74,15 +73,18 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
},
|
},
|
||||||
|
|
||||||
onReblog(status, e) {
|
onReblog(status, e) {
|
||||||
if (status.get('reblogged')) {
|
dispatch((_, getState) => {
|
||||||
dispatch(unreblog(status));
|
const boostModal = getState().getIn(['settings', 'boostModal']);
|
||||||
} else {
|
if (status.get('reblogged')) {
|
||||||
if (e.shiftKey || !boostModal) {
|
dispatch(unreblog(status));
|
||||||
this.onModalReblog(status);
|
|
||||||
} else {
|
} else {
|
||||||
dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
|
if (e.shiftKey || !boostModal) {
|
||||||
|
this.onModalReblog(status);
|
||||||
|
} else {
|
||||||
|
dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onFavourite(status) {
|
onFavourite(status) {
|
||||||
|
@ -109,15 +111,18 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
},
|
},
|
||||||
|
|
||||||
onDelete(status, history, withRedraft = false) {
|
onDelete(status, history, withRedraft = false) {
|
||||||
if (!deleteModal) {
|
dispatch((_, getState) => {
|
||||||
dispatch(deleteStatus(status.get('id'), history, withRedraft));
|
const deleteModal = getState().getIn(['settings', 'deleteModal']);
|
||||||
} else {
|
if (!deleteModal) {
|
||||||
dispatch(openModal('CONFIRM', {
|
dispatch(deleteStatus(status.get('id'), history, withRedraft));
|
||||||
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
|
} else {
|
||||||
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
|
dispatch(openModal('CONFIRM', {
|
||||||
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)),
|
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
|
||||||
}));
|
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
|
||||||
}
|
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onDirect(account, router) {
|
onDirect(account, router) {
|
||||||
|
|
|
@ -39,7 +39,6 @@ import { openModal } from '../../actions/modal';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import { HotKeys } from 'react-hotkeys';
|
import { HotKeys } from 'react-hotkeys';
|
||||||
import { boostModal, deleteModal } from '../../initial_state';
|
|
||||||
import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from '../ui/util/fullscreen';
|
import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from '../ui/util/fullscreen';
|
||||||
import { textForScreenReader, defaultMediaVisibility } from '../../components/status';
|
import { textForScreenReader, defaultMediaVisibility } from '../../components/status';
|
||||||
import Icon from 'gabsocial/components/icon';
|
import Icon from 'gabsocial/components/icon';
|
||||||
|
@ -195,29 +194,35 @@ class Status extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleReblogClick = (status, e) => {
|
handleReblogClick = (status, e) => {
|
||||||
if (status.get('reblogged')) {
|
this.props.dispatch((_, getState) => {
|
||||||
this.props.dispatch(unreblog(status));
|
const boostModal = getState().getIn(['settings', 'boostModal']);
|
||||||
} else {
|
if (status.get('reblogged')) {
|
||||||
if ((e && e.shiftKey) || !boostModal) {
|
this.props.dispatch(unreblog(status));
|
||||||
this.handleModalReblog(status);
|
|
||||||
} else {
|
} else {
|
||||||
this.props.dispatch(openModal('BOOST', { status, onReblog: this.handleModalReblog }));
|
if ((e && e.shiftKey) || !boostModal) {
|
||||||
|
this.handleModalReblog(status);
|
||||||
|
} else {
|
||||||
|
this.props.dispatch(openModal('BOOST', { status, onReblog: this.handleModalReblog }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDeleteClick = (status, history, withRedraft = false) => {
|
handleDeleteClick = (status, history, withRedraft = false) => {
|
||||||
const { dispatch, intl } = this.props;
|
const { dispatch, intl } = this.props;
|
||||||
|
|
||||||
if (!deleteModal) {
|
this.props.dispatch((_, getState) => {
|
||||||
dispatch(deleteStatus(status.get('id'), history, withRedraft));
|
const deleteModal = getState().getIn(['settings', 'deleteModal']);
|
||||||
} else {
|
if (!deleteModal) {
|
||||||
dispatch(openModal('CONFIRM', {
|
dispatch(deleteStatus(status.get('id'), history, withRedraft));
|
||||||
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
|
} else {
|
||||||
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
|
dispatch(openModal('CONFIRM', {
|
||||||
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)),
|
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
|
||||||
}));
|
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
|
||||||
}
|
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDirectClick = (account, router) => {
|
handleDirectClick = (account, router) => {
|
||||||
|
|
Loading…
Reference in a new issue