From 28411acebb5626acf43b44a7b6c33ac783156f72 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 9 Aug 2024 18:40:15 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20=E2=80=9CAccept=20all=E2=80=9D/=E2=80=9CD?= =?UTF-8?q?ismiss=20all=E2=80=9D=20notification=20requests=20not=20working?= =?UTF-8?q?=20(#31358)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/notifications/requests.jsx | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/app/javascript/mastodon/features/notifications/requests.jsx b/app/javascript/mastodon/features/notifications/requests.jsx index d5f191b734..f323bda4fb 100644 --- a/app/javascript/mastodon/features/notifications/requests.jsx +++ b/app/javascript/mastodon/features/notifications/requests.jsx @@ -74,9 +74,39 @@ const SelectRow = ({selectAllChecked, toggleSelectAll, selectedItems, selectionM const intl = useIntl(); const dispatch = useDispatch(); + const notificationRequests = useSelector(state => state.getIn(['notificationRequests', 'items'])); + const selectedCount = selectedItems.length; const handleAcceptAll = useCallback(() => { + const items = notificationRequests.map(request => request.get('id')).toArray(); + dispatch(openModal({ + modalType: 'CONFIRM', + modalProps: { + title: intl.formatMessage(messages.confirmAcceptAllTitle), + message: intl.formatMessage(messages.confirmAcceptAllMessage, { count: items.length }), + confirm: intl.formatMessage(messages.confirmAcceptAllButton), + onConfirm: () => + dispatch(acceptNotificationRequests(items)), + }, + })); + }, [dispatch, intl, notificationRequests]); + + const handleDismissAll = useCallback(() => { + const items = notificationRequests.map(request => request.get('id')).toArray(); + dispatch(openModal({ + modalType: 'CONFIRM', + modalProps: { + title: intl.formatMessage(messages.confirmDismissAllTitle), + message: intl.formatMessage(messages.confirmDismissAllMessage, { count: items.length }), + confirm: intl.formatMessage(messages.confirmDismissAllButton), + onConfirm: () => + dispatch(dismissNotificationRequests(items)), + }, + })); + }, [dispatch, intl, notificationRequests]); + + const handleAcceptMultiple = useCallback(() => { dispatch(openModal({ modalType: 'CONFIRM', modalProps: { @@ -89,7 +119,7 @@ const SelectRow = ({selectAllChecked, toggleSelectAll, selectedItems, selectionM })); }, [dispatch, intl, selectedItems]); - const handleDismissAll = useCallback(() => { + const handleDismissMultiple = useCallback(() => { dispatch(openModal({ modalType: 'CONFIRM', modalProps: { @@ -111,8 +141,8 @@ const SelectRow = ({selectAllChecked, toggleSelectAll, selectedItems, selectionM { text: intl.formatMessage(messages.acceptAll), action: handleAcceptAll }, { text: intl.formatMessage(messages.dismissAll), action: handleDismissAll }, ] : [ - { text: intl.formatMessage(messages.acceptMultiple, { count: selectedCount }), action: handleAcceptAll }, - { text: intl.formatMessage(messages.dismissMultiple, { count: selectedCount }), action: handleDismissAll }, + { text: intl.formatMessage(messages.acceptMultiple, { count: selectedCount }), action: handleAcceptMultiple }, + { text: intl.formatMessage(messages.dismissMultiple, { count: selectedCount }), action: handleDismissMultiple }, ]; return (