diff --git a/src/client/components/Sidebar/LastDrafts.js b/src/client/components/Sidebar/LastDrafts.js index bec8e25040..00a510a375 100644 --- a/src/client/components/Sidebar/LastDrafts.js +++ b/src/client/components/Sidebar/LastDrafts.js @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage, FormattedRelative } from 'react-intl'; import { Link } from 'react-router-dom'; +import { draftType, draftArrayType } from '../../types/drafts'; import Loading from '../../components/Icon/Loading'; import './LastDrafts.less'; import './SidebarContentBlock.less'; @@ -21,7 +22,7 @@ const Draft = ({ draft }) => ( ); Draft.propTypes = { - draft: PropTypes.shape().isRequired, + draft: draftType.isRequired, }; const LastDrafts = ({ drafts, loaded }) => { @@ -55,7 +56,7 @@ const LastDrafts = ({ drafts, loaded }) => { }; LastDrafts.propTypes = { - drafts: PropTypes.arrayOf(PropTypes.shape({ id: PropTypes.string, title: PropTypes.string })), + drafts: draftArrayType, loaded: PropTypes.bool, }; diff --git a/src/client/post/Write/DraftRow.js b/src/client/post/Write/DraftRow.js index 2470b5a2b4..8c694c077d 100644 --- a/src/client/post/Write/DraftRow.js +++ b/src/client/post/Write/DraftRow.js @@ -4,13 +4,14 @@ import _ from 'lodash'; import { FormattedMessage, FormattedRelative } from 'react-intl'; import { Link } from 'react-router-dom'; import { Checkbox } from 'antd'; +import { draftType } from '../../types/drafts'; import DeleteDraftModal from './DeleteDraftModal'; import './DraftRow.less'; class DraftRow extends React.Component { static propTypes = { id: PropTypes.string.isRequired, - data: PropTypes.shape().isRequired, + draft: draftType.isRequired, selected: PropTypes.bool, onCheck: PropTypes.func, }; @@ -46,10 +47,10 @@ class DraftRow extends React.Component { } render() { - const { id, data, selected } = this.props; - const { lastUpdated } = data; + const { id, draft, selected } = this.props; + const { lastUpdated } = draft; const hasLastUpdated = !_.isUndefined(lastUpdated); - let { title = '', body = '' } = data; + let { title = '', body = '' } = draft; title = title.trim(); body = body.replace(/\r?\n|\r|[\u200B-\u200D\uFEFF]/g, ' ').substring(0, 50); let draftTitle = title.length ? title : body; diff --git a/src/client/post/Write/Drafts.js b/src/client/post/Write/Drafts.js index e32da1232e..02c370e8f6 100644 --- a/src/client/post/Write/Drafts.js +++ b/src/client/post/Write/Drafts.js @@ -149,7 +149,7 @@ class Drafts extends React.Component { _.map(sortedDraftPosts, draft => (