added support to copy comment text...

This commit is contained in:
noumantahir 2021-09-17 12:21:03 +05:00
parent c00508ccce
commit 0e91814dfe
3 changed files with 20 additions and 11 deletions

View File

@ -4,6 +4,7 @@ import { connect } from 'react-redux';
import { injectIntl } from 'react-intl';
import get from 'lodash/get';
import { postBodySummary } from '@ecency/render-helper';
import { getComments, deleteComment } from '../../../providers/hive/dhive';
// Services and Actions
import { writeToClipboard } from '../../../utils/clipboard';
@ -212,17 +213,23 @@ const CommentsContainer = ({
};
const _handleOnPressCommentMenu = (index, selectedComment) => {
const _showCopiedToast = () => {
dispatch(
toastNotification(
intl.formatMessage({
id: 'alert.copied',
}),
),
);
};
if (index === 0) {
writeToClipboard(`https://ecency.com${get(selectedComment, 'url')}`).then(() => {
dispatch(
toastNotification(
intl.formatMessage({
id: 'alert.copied',
}),
),
);
});
} else if (index === 1) {
writeToClipboard(`https://ecency.com${get(selectedComment, 'url')}`).then(_showCopiedToast);
}
if (index === 1) {
const body = postBodySummary(selectedComment.markdownBody);
writeToClipboard(body).then(_showCopiedToast);
} else if (index === 2) {
_openReplyThread(selectedComment);
}
};

View File

@ -78,6 +78,7 @@ const CommentsView = ({
const menuItems = [
intl.formatMessage({ id: 'post.copy_link' }),
intl.formatMessage({ id: 'post.copy_text' }),
intl.formatMessage({ id: 'post.open_thread' }),
intl.formatMessage({ id: 'alert.cancel' }),
];
@ -145,7 +146,7 @@ const CommentsView = ({
ref={commentMenu}
options={menuItems}
title={get(selectedComment, 'summary')}
cancelButtonIndex={2}
cancelButtonIndex={3}
onPress={_onMenuItemPress}
/>
</Fragment>

View File

@ -426,6 +426,7 @@
"reblog_alert": "Are you sure, you want to reblog?",
"removed_hint": "Content is not available",
"copy_link": "Copy link",
"copy_text": "Copy text",
"reblogged": "reblogged by",
"sponsored": "SPONSORED",
"open_thread": "Open thread",