mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-56849] Convert ./components/post_view/failed_post_options/failed_post_options.tsx
from Class Component to Function Component (#26234)
Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
bff19228e1
commit
95e85db811
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import React, {memo, useCallback} from 'react';
|
||||
import type {MouseEvent} from 'react';
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
|
||||
@ -18,28 +18,30 @@ type Props = {
|
||||
};
|
||||
};
|
||||
|
||||
export default class FailedPostOptions extends React.PureComponent<Props> {
|
||||
retryPost = (e: MouseEvent): void => {
|
||||
const FailedPostOptions = ({
|
||||
post,
|
||||
actions,
|
||||
}: Props) => {
|
||||
const retryPost = useCallback((e: MouseEvent): void => {
|
||||
e.preventDefault();
|
||||
|
||||
const post = {...this.props.post};
|
||||
Reflect.deleteProperty(post, 'id');
|
||||
this.props.actions.createPost(post, []);
|
||||
};
|
||||
const postDetails = {...post};
|
||||
Reflect.deleteProperty(postDetails, 'id');
|
||||
actions.createPost(postDetails, []);
|
||||
}, [actions, post]);
|
||||
|
||||
cancelPost = (e: MouseEvent): void => {
|
||||
const cancelPost = useCallback((e: MouseEvent): void => {
|
||||
e.preventDefault();
|
||||
|
||||
this.props.actions.removePost(this.props.post);
|
||||
};
|
||||
actions.removePost(post);
|
||||
}, [actions, post]);
|
||||
|
||||
render(): JSX.Element {
|
||||
return (
|
||||
<span className='pending-post-actions'>
|
||||
<a
|
||||
className='post-retry'
|
||||
href='#'
|
||||
onClick={this.retryPost}
|
||||
onClick={retryPost}
|
||||
>
|
||||
<FormattedMessage
|
||||
id='pending_post_actions.retry'
|
||||
@ -50,7 +52,7 @@ export default class FailedPostOptions extends React.PureComponent<Props> {
|
||||
<a
|
||||
className='post-cancel'
|
||||
href='#'
|
||||
onClick={this.cancelPost}
|
||||
onClick={cancelPost}
|
||||
>
|
||||
<FormattedMessage
|
||||
id='pending_post_actions.cancel'
|
||||
@ -59,5 +61,6 @@ export default class FailedPostOptions extends React.PureComponent<Props> {
|
||||
</a>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default memo(FailedPostOptions);
|
||||
|
Loading…
Reference in New Issue
Block a user