From 14030312b6e099539e500302269a125a31c5fe27 Mon Sep 17 00:00:00 2001 From: Ittihadyya Date: Thu, 9 Oct 2025 13:15:57 +0300 Subject: [PATCH] Implemented functionality for the setting governing delete confirmation dialogs --- .../glitch/containers/status_container.js | 28 ++++++++++--------- .../flavours/glitch/features/status/index.jsx | 4 +-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/javascript/flavours/glitch/containers/status_container.js b/app/javascript/flavours/glitch/containers/status_container.js index d80c50b1b294ac5b440d104dcd7cb6759ee5485a..855db656946527a8dc6083a9d3765aa78ca8ab6d 100644 --- a/app/javascript/flavours/glitch/containers/status_container.js +++ b/app/javascript/flavours/glitch/containers/status_container.js @@ -38,7 +38,7 @@ import { undoStatusTranslation, } from 'flavours/glitch/actions/statuses'; import Status from 'flavours/glitch/components/status'; -import { favouriteModal, deleteModal } from 'flavours/glitch/initial_state'; +import { favouriteModal } from 'flavours/glitch/initial_state'; import { makeGetStatus, makeGetPictureInPicture } from 'flavours/glitch/selectors'; import { showAlertForError } from '../actions/alerts'; @@ -184,18 +184,20 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({ }, onDelete (status, history, withRedraft = false) { - if (state.getIn(['local_settings', 'confirm_delete']) ) { - dispatch(deleteStatus(status.get('id'), history, withRedraft)); - } else { - dispatch(openModal({ - modalType: 'CONFIRM', - modalProps: { - message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage), - confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm), - onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)), - }, - })); - } + dispatch((_, getState) => { + let state = getState(); // state used to be passed as a global variable through `deleteModal`, but everything else works like this (see non-described media and clearing drafts, for example) + if (!state.getIn(['local_settings', 'confirm_delete'])) { + dispatch(deleteStatus(status.get('id'), history, withRedraft)); + } else { + dispatch(openModal({ + modalType: 'CONFIRM', + modalProps: { + message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage), + confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm), + onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)), + }, + }))}; + }); }, onEdit (status, history) { diff --git a/app/javascript/flavours/glitch/features/status/index.jsx b/app/javascript/flavours/glitch/features/status/index.jsx index 5e48dd7ebc48fcb25df6954d776253e738f243e7..9f9ba92e87df24661ecfb5a01e47af18bc83e3cc 100644 --- a/app/javascript/flavours/glitch/features/status/index.jsx +++ b/app/javascript/flavours/glitch/features/status/index.jsx @@ -52,7 +52,7 @@ import ScrollContainer from 'flavours/glitch/containers/scroll_container'; import StatusContainer from 'flavours/glitch/containers/status_container'; import BundleColumnError from 'flavours/glitch/features/ui/components/bundle_column_error'; import Column from 'flavours/glitch/features/ui/components/column'; -import { favouriteModal, deleteModal } from 'flavours/glitch/initial_state'; +import { favouriteModal } from 'flavours/glitch/initial_state'; import { makeGetStatus, makeGetPictureInPicture } from 'flavours/glitch/selectors'; import { autoUnfoldCW } from 'flavours/glitch/utils/content_warning'; @@ -385,7 +385,7 @@ class Status extends ImmutablePureComponent { handleDeleteClick = (status, history, withRedraft = false) => { const { dispatch, intl } = this.props; - if (!deleteModal) { + if (!settings.get('confirm_delete')) { dispatch(deleteStatus(status.get('id'), history, withRedraft)); } else { dispatch(openModal({