Merge pull request #681 from esteemapp/bugfix/edit-markdown

Bugfix/edit markdown
This commit is contained in:
Mustafa Buyukcelebi 2019-03-17 00:31:43 +03:00 committed by GitHub
commit 11771cc6c8
5 changed files with 36 additions and 33 deletions

View File

@ -9,3 +9,4 @@ PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/. PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods PODS_ROOT = ${SRCROOT}/Pods
USER_HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/FLAnimatedImage/FLAnimatedImage

View File

@ -9,3 +9,4 @@ PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/. PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods PODS_ROOT = ${SRCROOT}/Pods
USER_HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/FLAnimatedImage/FLAnimatedImage

View File

@ -8,3 +8,4 @@ PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/. PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods PODS_ROOT = ${SRCROOT}/Pods
USER_HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/FLAnimatedImage/FLAnimatedImage

View File

@ -8,3 +8,4 @@ PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/. PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods PODS_ROOT = ${SRCROOT}/Pods
USER_HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/FLAnimatedImage/FLAnimatedImage

View File

@ -3,58 +3,57 @@ import { markDown2Html } from './markdownToHtml';
import { getPostSummary } from './formatter'; import { getPostSummary } from './formatter';
import { getReputation } from './reputation'; import { getReputation } from './reputation';
export const parsePosts = (posts, currentUserName, isSummary) => (!posts ? null : posts.map(post => parsePost(post, currentUserName, isSummary))); export const parsePosts = (posts, currentUserName) => (!posts ? null : posts.map(post => parsePost(post, currentUserName)));
export const parsePost = (post, currentUserName, isSummary = false) => { export const parsePost = (post, currentUserName) => {
if (!post) { if (!post) {
return null; return null;
} }
const _post = post;
_post.json_metadata = JSON.parse(post.json_metadata); if (currentUserName === post.author) {
_post.image = postImage(post.json_metadata, post.body); post.markdownBody = post.body;
_post.vote_count = post.active_votes.length; }
_post.author_reputation = getReputation(post.author_reputation);
_post.avatar = `https://steemitimages.com/u/${post.author}/avatar/small`;
_post.active_votes.sort((a, b) => b.rshares - a.rshares);
_post.body = markDown2Html(post.body); post.json_metadata = JSON.parse(post.json_metadata);
_post.summary = getPostSummary(post.body, 150); post.image = postImage(post.json_metadata, post.body);
_post.is_declined_payout = Number(parseFloat(post.max_accepted_payout)) === 0; post.vote_count = post.active_votes.length;
post.author_reputation = getReputation(post.author_reputation);
post.avatar = `https://steemitimages.com/u/${post.author}/avatar/small`;
post.active_votes.sort((a, b) => b.rshares - a.rshares);
post.body = markDown2Html(post.body);
post.summary = getPostSummary(post.body, 150);
post.is_declined_payout = Number(parseFloat(post.max_accepted_payout)) === 0;
if (currentUserName) { if (currentUserName) {
_post.is_voted = isVoted(_post.active_votes, currentUserName); post.is_voted = isVoted(post.active_votes, currentUserName);
} else { } else {
_post.is_voted = false; post.is_voted = false;
} }
if (currentUserName === _post.author) { const totalPayout = parseFloat(post.pending_payout_value)
_post.markdownBody = post.body; + parseFloat(post.total_payout_value)
} + parseFloat(post.curator_payout_value);
const totalPayout = parseFloat(_post.pending_payout_value) post.total_payout = totalPayout.toFixed(3);
+ parseFloat(_post.total_payout_value)
+ parseFloat(_post.curator_payout_value);
_post.total_payout = totalPayout.toFixed(3); const voteRshares = post.active_votes.reduce((a, b) => a + parseFloat(b.rshares), 0);
const voteRshares = _post.active_votes.reduce((a, b) => a + parseFloat(b.rshares), 0);
const ratio = totalPayout / voteRshares; const ratio = totalPayout / voteRshares;
if (_post.active_votes && _post.active_votes.length > 0) { if (post.active_votes && post.active_votes.length > 0) {
for (const i in _post.active_votes) { 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].value = (post.active_votes[i].rshares * ratio).toFixed(3);
_post.active_votes[i].reputation = getReputation(post.active_votes[i].reputation); post.active_votes[i].reputation = getReputation(post.active_votes[i].reputation);
_post.active_votes[i].percent = post.active_votes[i].percent / 100; post.active_votes[i].percent = post.active_votes[i].percent / 100;
_post.active_votes[i].is_down_vote = Math.sign(post.active_votes[i].percent) < 0; post.active_votes[i].is_down_vote = Math.sign(post.active_votes[i].percent) < 0;
_post.active_votes[i].avatar = `https://steemitimages.com/u/${ post.active_votes[i].avatar = `https://steemitimages.com/u/${
_post.active_votes[i].voter post.active_votes[i].voter
}/avatar/small`; }/avatar/small`;
} }
} }
return _post; 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);