~cytrogen/masto-fe

ref: 1ff70886a12e05cdc2f0789e78dcdabccaef6d18 masto-fe/app/javascript/flavours/glitch/containers/notification_purge_buttons_container.js -rw-r--r-- 1.5 KiB
1ff70886 — Zoë Bijl [build] upgrade eslint to 9.37.0 (#88) 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//  Package imports.
import { defineMessages, injectIntl } from "react-intl";

import { connect } from "react-redux";

//  Our imports.
import { openModal } from "flavours/glitch/actions/modal";
import {
  deleteMarkedNotifications,
  enterNotificationClearingMode,
  markAllNotifications,
} from "flavours/glitch/actions/notifications";
import NotificationPurgeButtons from "flavours/glitch/components/notification_purge_buttons";

const messages = defineMessages({
  clearMessage: { id: "notifications.marked_clear_confirmation", defaultMessage: "Are you sure you want to permanently clear all selected notifications?" },
  clearConfirm: { id: "notifications.marked_clear", defaultMessage: "Clear selected notifications" },
});

const mapDispatchToProps = (dispatch, { intl }) => ({
  onEnterCleaningMode(yes) {
    dispatch(enterNotificationClearingMode(yes));
  },

  onDeleteMarked() {
    dispatch(openModal({
      modalType: "CONFIRM",
      modalProps: {
        message: intl.formatMessage(messages.clearMessage),
        confirm: intl.formatMessage(messages.clearConfirm),
        onConfirm: () => dispatch(deleteMarkedNotifications()),
      },
    }));
  },

  onMarkAll() {
    dispatch(markAllNotifications(true));
  },

  onMarkNone() {
    dispatch(markAllNotifications(false));
  },

  onInvert() {
    dispatch(markAllNotifications(null));
  },
});

const mapStateToProps = state => ({
  markNewForDelete: state.getIn(["notifications", "markNewForDelete"]),
});

export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(NotificationPurgeButtons));