From 9818f342735d1765baa281aaeeab2f60b8d049fe Mon Sep 17 00:00:00 2001
From: fusagiko / takayamaki <24884114+takayamaki@users.noreply.github.com>
Date: Mon, 8 May 2023 22:12:12 +0900
Subject: [PATCH] Rewrite Domain component as function component (#24896)
---
app/javascript/mastodon/components/domain.jsx | 43 -------------------
app/javascript/mastodon/components/domain.tsx | 42 ++++++++++++++++++
.../mastodon/containers/domain_container.jsx | 2 +-
3 files changed, 43 insertions(+), 44 deletions(-)
delete mode 100644 app/javascript/mastodon/components/domain.jsx
create mode 100644 app/javascript/mastodon/components/domain.tsx
diff --git a/app/javascript/mastodon/components/domain.jsx b/app/javascript/mastodon/components/domain.jsx
deleted file mode 100644
index 85ebdbde93..0000000000
--- a/app/javascript/mastodon/components/domain.jsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import IconButton from './icon_button';
-import { defineMessages, injectIntl } from 'react-intl';
-import ImmutablePureComponent from 'react-immutable-pure-component';
-
-const messages = defineMessages({
- unblockDomain: { id: 'account.unblock_domain', defaultMessage: 'Unblock domain {domain}' },
-});
-
-class Account extends ImmutablePureComponent {
-
- static propTypes = {
- domain: PropTypes.string,
- onUnblockDomain: PropTypes.func.isRequired,
- intl: PropTypes.object.isRequired,
- };
-
- handleDomainUnblock = () => {
- this.props.onUnblockDomain(this.props.domain);
- };
-
- render () {
- const { domain, intl } = this.props;
-
- return (
-
- );
- }
-
-}
-
-export default injectIntl(Account);
diff --git a/app/javascript/mastodon/components/domain.tsx b/app/javascript/mastodon/components/domain.tsx
new file mode 100644
index 0000000000..6cb8f7b8ff
--- /dev/null
+++ b/app/javascript/mastodon/components/domain.tsx
@@ -0,0 +1,42 @@
+import React, { useCallback } from 'react';
+import IconButton from './icon_button';
+import { InjectedIntl, defineMessages, injectIntl } from 'react-intl';
+
+const messages = defineMessages({
+ unblockDomain: {
+ id: 'account.unblock_domain',
+ defaultMessage: 'Unblock domain {domain}',
+ },
+});
+
+type Props = {
+ domain: string;
+ onUnblockDomain: (domain: string) => void;
+ intl: InjectedIntl;
+};
+const _Domain: React.FC = ({ domain, onUnblockDomain, intl }) => {
+ const handleDomainUnblock = useCallback(() => {
+ onUnblockDomain(domain);
+ }, [domain, onUnblockDomain]);
+
+ return (
+
+ );
+};
+
+export const Domain = injectIntl(_Domain);
diff --git a/app/javascript/mastodon/containers/domain_container.jsx b/app/javascript/mastodon/containers/domain_container.jsx
index 8a8ba1df12..419d5d29f5 100644
--- a/app/javascript/mastodon/containers/domain_container.jsx
+++ b/app/javascript/mastodon/containers/domain_container.jsx
@@ -2,7 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { blockDomain, unblockDomain } from '../actions/domain_blocks';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
-import Domain from '../components/domain';
+import { Domain } from '../components/domain';
import { openModal } from '../actions/modal';
const messages = defineMessages({