Add preference setting for delete toot modal (#3368)

* Set delete_modal preference to true by default
* Does not show confirmation modal if delete_modal is false
* Add ja translation for preference setting page
This commit is contained in:
Atsushi Yamamoto
2017-05-29 11:56:13 -04:00
committed by Eugen Rochko
parent b5e8994844
commit 402c19a924
12 changed files with 46 additions and 10 deletions

View File

@ -35,6 +35,7 @@ class Settings::PreferencesController < ApplicationController
params.require(:user).permit(
:setting_default_privacy,
:setting_boost_modal,
:setting_delete_modal,
:setting_auto_play_gif,
notification_emails: %i(follow follow_request reblog favourite mention digest),
interactions: %i(must_be_follower must_be_following)

View File

@ -37,6 +37,7 @@ const makeMapStateToProps = () => {
status: getStatus(state, props.id),
me: state.getIn(['meta', 'me']),
boostModal: state.getIn(['meta', 'boost_modal']),
deleteModal: state.getIn(['meta', 'delete_modal']),
autoPlayGif: state.getIn(['meta', 'auto_play_gif']),
});
@ -74,11 +75,15 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
},
onDelete (status) {
dispatch(openModal('CONFIRM', {
message: intl.formatMessage(messages.deleteMessage),
confirm: intl.formatMessage(messages.deleteConfirm),
onConfirm: () => dispatch(deleteStatus(status.get('id'))),
}));
if (!this.deleteModal) {
dispatch(deleteStatus(status.get('id')));
} else {
dispatch(openModal('CONFIRM', {
message: intl.formatMessage(messages.deleteMessage),
confirm: intl.formatMessage(messages.deleteConfirm),
onConfirm: () => dispatch(deleteStatus(status.get('id'))),
}));
}
},
onMention (account, router) {

View File

@ -48,6 +48,7 @@ const makeMapStateToProps = () => {
descendantsIds: state.getIn(['timelines', 'descendants', Number(props.params.statusId)]),
me: state.getIn(['meta', 'me']),
boostModal: state.getIn(['meta', 'boost_modal']),
deleteModal: state.getIn(['meta', 'delete_modal']),
autoPlayGif: state.getIn(['meta', 'auto_play_gif']),
});
@ -68,6 +69,7 @@ class Status extends ImmutablePureComponent {
descendantsIds: ImmutablePropTypes.list,
me: PropTypes.number,
boostModal: PropTypes.bool,
deleteModal: PropTypes.bool,
autoPlayGif: PropTypes.bool,
intl: PropTypes.object.isRequired,
};
@ -113,11 +115,15 @@ class Status extends ImmutablePureComponent {
handleDeleteClick = (status) => {
const { dispatch, intl } = this.props;
dispatch(openModal('CONFIRM', {
message: intl.formatMessage(messages.deleteMessage),
confirm: intl.formatMessage(messages.deleteConfirm),
onConfirm: () => dispatch(deleteStatus(status.get('id'))),
}));
if (!this.props.deleteModal) {
dispatch(deleteStatus(status.get('id')));
} else {
dispatch(openModal('CONFIRM', {
message: intl.formatMessage(messages.deleteMessage),
confirm: intl.formatMessage(messages.deleteConfirm),
onConfirm: () => dispatch(deleteStatus(status.get('id'))),
}));
}
}
handleMentionClick = (account, router) => {

View File

@ -19,6 +19,7 @@ class UserSettingsDecorator
user.settings['interactions'] = merged_interactions
user.settings['default_privacy'] = default_privacy_preference
user.settings['boost_modal'] = boost_modal_preference
user.settings['delete_modal'] = delete_modal_preference
user.settings['auto_play_gif'] = auto_play_gif_preference
end
@ -38,6 +39,10 @@ class UserSettingsDecorator
boolean_cast_setting 'setting_boost_modal'
end
def delete_modal_preference
boolean_cast_setting 'setting_delete_modal'
end
def auto_play_gif_preference
boolean_cast_setting 'setting_auto_play_gif'
end

View File

@ -80,6 +80,10 @@ class User < ApplicationRecord
settings.boost_modal
end
def setting_delete_modal
settings.delete_modal
end
def setting_auto_play_gif
settings.auto_play_gif
end

View File

@ -9,6 +9,7 @@ node(:meta) do
me: current_account.id,
admin: @admin.try(:id),
boost_modal: current_account.user.setting_boost_modal,
delete_modal: current_account.user.setting_delete_modal,
auto_play_gif: current_account.user.setting_auto_play_gif,
}
end

View File

@ -40,6 +40,7 @@
.fields-group
= f.input :setting_boost_modal, as: :boolean, wrapper: :with_label
= f.input :setting_delete_modal, as: :boolean, wrapper: :with_label
.fields-group
= f.input :setting_auto_play_gif, as: :boolean, wrapper: :with_label