mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-21 20:31:37 +03:00
fixed comment bug
This commit is contained in:
parent
8b38141c61
commit
fb5a1a6d27
@ -90,10 +90,14 @@ class EditorContainer extends Component {
|
||||
this.setState(
|
||||
{
|
||||
isEdit,
|
||||
draftPost: { title: post.title, body: post.markdownBody, tags: post.json_metadata.tags },
|
||||
draftPost: {
|
||||
title: post.title,
|
||||
body: post.markdownBody,
|
||||
tags: post.json_metadata.tags,
|
||||
},
|
||||
},
|
||||
() => {
|
||||
this._getPurePost(post.author, post.permlink);
|
||||
// this._getPurePost(post.author, post.permlink);
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -293,8 +297,8 @@ class EditorContainer extends Component {
|
||||
|
||||
_submitPost = async (fields) => {
|
||||
const {
|
||||
navigation, currentAccount, pinCode, intl, isDefaultFooter,
|
||||
} = this.props;
|
||||
navigation, currentAccount, pinCode, intl, isDefaultFooter
|
||||
} = this.props;
|
||||
|
||||
if (currentAccount) {
|
||||
this.setState({ isPostSending: true });
|
||||
@ -411,14 +415,19 @@ class EditorContainer extends Component {
|
||||
} = post;
|
||||
|
||||
let newBody = fields.body;
|
||||
let _oldMeta = oldMeta;
|
||||
const patch = createPatch(oldBody, newBody.trim());
|
||||
|
||||
if (patch && patch.length < Buffer.from(oldBody, 'utf-8').length) {
|
||||
newBody = patch;
|
||||
}
|
||||
|
||||
if (typeof _oldMeta === 'string') {
|
||||
_oldMeta = JSON.parse(_oldMeta);
|
||||
}
|
||||
|
||||
const meta = extractMetadata(fields.body);
|
||||
const metadata = Object.assign({}, oldMeta, meta);
|
||||
const metadata = Object.assign({}, _oldMeta, meta);
|
||||
const jsonMeta = makeJsonMetadata(metadata, fields.tags);
|
||||
|
||||
await postContent(
|
||||
|
@ -84,11 +84,11 @@ export const makeJsonMetadataReply = tags => ({
|
||||
});
|
||||
|
||||
export const makeJsonMetadata = (meta, tags) => Object.assign({}, meta, {
|
||||
tags,
|
||||
app: 'esteem/2.0.0-mobile',
|
||||
format: 'markdown+html',
|
||||
community: 'esteem.app',
|
||||
});
|
||||
tags,
|
||||
app: 'esteem/2.0.0-mobile',
|
||||
format: 'markdown+html',
|
||||
community: 'esteem.app',
|
||||
});
|
||||
|
||||
export const extractMetadata = (body) => {
|
||||
const urlReg = /(\b(https?|ftp):\/\/[A-Z0-9+&@#/%?=~_|!:,.;-]*[-A-Z0-9+&@#/%=~_|])/gim;
|
||||
|
@ -3,7 +3,8 @@ import { markDown2Html } from './markdownToHtml';
|
||||
import { getPostSummary } from './formatter';
|
||||
import { getReputation } from './reputation';
|
||||
|
||||
export const parsePosts = (posts, currentUserName) => (!posts ? null : posts.map(post => parsePost(post, currentUserName)));
|
||||
export const parsePosts = (posts, currentUserName) =>
|
||||
!posts ? null : posts.map(post => parsePost(post, currentUserName));
|
||||
|
||||
export const parsePost = (post, currentUserName) => {
|
||||
if (!post) {
|
||||
@ -31,9 +32,10 @@ export const parsePost = (post, currentUserName) => {
|
||||
post.is_voted = false;
|
||||
}
|
||||
|
||||
const totalPayout = parseFloat(post.pending_payout_value)
|
||||
+ parseFloat(post.total_payout_value)
|
||||
+ parseFloat(post.curator_payout_value);
|
||||
const totalPayout =
|
||||
parseFloat(post.pending_payout_value) +
|
||||
parseFloat(post.total_payout_value) +
|
||||
parseFloat(post.curator_payout_value);
|
||||
|
||||
post.total_payout = totalPayout.toFixed(3);
|
||||
|
||||
@ -42,7 +44,8 @@ export const parsePost = (post, currentUserName) => {
|
||||
|
||||
if (post.active_votes && post.active_votes.length > 0) {
|
||||
for (const i in post.active_votes) {
|
||||
post.vote_perecent = post.active_votes[i].voter === currentUserName ? post.active_votes[i].percent : null;
|
||||
post.vote_perecent =
|
||||
post.active_votes[i].voter === currentUserName ? post.active_votes[i].percent : null;
|
||||
post.active_votes[i].value = (post.active_votes[i].rshares * ratio).toFixed(3);
|
||||
post.active_votes[i].reputation = getReputation(post.active_votes[i].reputation);
|
||||
post.active_votes[i].percent = post.active_votes[i].percent / 100;
|
||||
@ -56,7 +59,8 @@ export const parsePost = (post, currentUserName) => {
|
||||
return post;
|
||||
};
|
||||
|
||||
const isVoted = (activeVotes, currentUserName) => activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
|
||||
const isVoted = (activeVotes, currentUserName) =>
|
||||
activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
|
||||
|
||||
const postImage = (metaData, body) => {
|
||||
const imgTagRegex = /(<img[^>]*>)/g;
|
||||
@ -131,12 +135,13 @@ const postImage = (metaData, body) => {
|
||||
// }
|
||||
// };
|
||||
|
||||
export const parseComments = (comments) => {
|
||||
comments.map((comment) => {
|
||||
export const parseComments = comments => {
|
||||
comments.map(comment => {
|
||||
comment.pending_payout_value = parseFloat(comment.pending_payout_value).toFixed(3);
|
||||
comment.vote_count = comment.active_votes.length;
|
||||
comment.author_reputation = getReputation(comment.author_reputation);
|
||||
comment.avatar = `https://steemitimages.com/u/${comment.author}/avatar/small`;
|
||||
comment.markdownBody = comment.body;
|
||||
comment.body = markDown2Html(comment.body);
|
||||
comment.summary = getPostSummary(comment.body, 100, true);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user