fixes and improvements

This commit is contained in:
feruz 2020-08-14 11:34:43 +03:00
parent 94fa85bba4
commit bde4c33787
9 changed files with 34 additions and 19 deletions

View File

@ -28,7 +28,7 @@
"dependencies": {
"@babel/runtime": "^7.5.5",
"@esteemapp/dhive": "^0.15.0",
"@esteemapp/esteem-render-helpers": "^1.5.6",
"@esteemapp/esteem-render-helpers": "^1.5.9",
"@esteemapp/react-native-autocomplete-input": "^4.2.1",
"@esteemapp/react-native-modal-popover": "^0.0.15",
"@esteemapp/react-native-multi-slider": "^1.1.0",

View File

@ -60,7 +60,8 @@ export default class TitleAreaView extends Component {
placeholder={intl.formatMessage({
id: 'editor.title',
})}
numberOfLines={1}
multiline
numberOfLines={2}
onContentSizeChange={(event) => {
this.setState({ height: event.nativeEvent.contentSize.height });
}}

View File

@ -140,7 +140,11 @@ const MarkdownEditorView = ({
const _renderPreview = () => (
<ScrollView style={styles.previewContainer}>
{text ? <PostBody body={renderPostBody(text)} /> : <Text>...</Text>}
{text ? (
<PostBody body={renderPostBody(text, true, Platform.OS === 'ios' ? false : true)} />
) : (
<Text>...</Text>
)}
</ScrollView>
);

View File

@ -31,6 +31,7 @@ document.addEventListener('click', function(event) {
return;
}
if (el.getAttribute('target') === '_external') {
event.preventDefault();
var href = el.getAttribute('href');
var result = {
type: '_external',
@ -40,6 +41,7 @@ document.addEventListener('click', function(event) {
return true;
}
if (el.classList.contains('markdown-external-link')) {
event.preventDefault();
var href = el.getAttribute('data-href');
var result = {
type: 'markdown-external-link',
@ -168,6 +170,7 @@ document.addEventListener('click', function(event) {
return;
}
if (el.getAttribute('target') === '_external') {
event.preventDefault();
var href = el.getAttribute('href');
var result = {
type: '_external',
@ -177,6 +180,7 @@ document.addEventListener('click', function(event) {
return true;
}
if (el.classList.contains('markdown-external-link')) {
event.preventDefault();
var href = el.getAttribute('data-href');
var result = {
type: 'markdown-external-link',

View File

@ -1,4 +1,5 @@
import steemConnect from './steemConnectAPI';
import { makeOptions } from '../../utils/editor';
/**
* @method to upvote/unvote a content
@ -59,7 +60,7 @@ export const post = (postObj) => {
];
operations.push(commentOp);
const commentOptionsConfig = prepareBeneficiaries(postObj);
const commentOptionsConfig = makeOptions(postObj);
operations.push(commentOptionsConfig);

View File

@ -309,7 +309,7 @@ class EditorContainer extends Component {
}
const author = currentAccount.name;
const options = makeOptions(author, permlink);
const options = makeOptions({ author: author, permlink: permlink, operationType: '' });
const parentPermlink = _tags[0] || 'hive-125125';
if (scheduleDate) {
@ -384,7 +384,7 @@ class EditorContainer extends Component {
const jsonMeta = makeJsonMetadataReply(post.json_metadata.tags || ['ecency']);
const permlink = generateReplyPermlink(post.author);
const author = currentAccount.name;
const options = makeOptions(author, permlink);
const options = makeOptions({ author: author, permlink: permlink, operationType: '' });
const parentAuthor = post.author;
const parentPermlink = post.permlink;

View File

@ -57,35 +57,38 @@ export const generateReplyPermlink = (toAuthor) => {
return `re-${toAuthor.replace(/\./g, '')}-${timeFormat}`;
};
export const makeOptions = (author, permlink, operationType) => {
if (!author || !permlink) {
export const makeOptions = (postObj) => {
if (!postObj.author || !postObj.permlink) {
return {};
}
const a = {
allow_curation_rewards: true,
allow_votes: true,
author,
permlink,
author: postObj.author,
permlink: postObj.permlink,
max_accepted_payout: '1000000.000 HBD',
percent_steem_dollars: 10000,
extensions: [[0, { beneficiaries: [{ account: 'ecency', weight: 100 }] }]],
extensions: [],
};
switch (operationType) {
switch (postObj.operationType) {
case 'sp':
a.max_accepted_payout = '1000000.000 HBD';
a.percent_steem_dollars = 0;
a.extensions = postObj.beneficiaries || [];
break;
case 'dp':
a.max_accepted_payout = '0.000 HBD';
a.percent_steem_dollars = 10000;
a.extensions = postObj.beneficiaries || [];
break;
default:
a.max_accepted_payout = '1000000.000 HBD';
a.percent_steem_dollars = 10000;
a.extensions = postObj.beneficiaries || [];
break;
}

View File

@ -1,7 +1,7 @@
import isEmpty from 'lodash/isEmpty';
import forEach from 'lodash/forEach';
import { get, uniqBy } from 'lodash';
import { Platform } from 'react-native';
import { postBodySummary, renderPostBody } from '@esteemapp/esteem-render-helpers';
// Dsteem
@ -13,6 +13,8 @@ import { getPostReblogs } from '../providers/esteem/esteem';
import { getReputation } from './reputation';
import { getResizedImage, getResizedAvatar } from './image';
const webp = Platform.OS === 'ios' ? false : true;
export const parsePosts = async (posts, currentUserName) => {
if (posts) {
const promises = posts.map((post) => parsePost(post, currentUserName));
@ -43,7 +45,7 @@ export const parsePost = async (post, currentUserName, isPromoted) => {
post.avatar = getResizedAvatar(get(post, 'author'));
post.active_votes.sort((a, b) => b.rshares - a.rshares);
post.body = renderPostBody(post);
post.body = renderPostBody(post, true, webp);
post.summary = postBodySummary(post, 150);
post.is_declined_payout = Number(parseFloat(post.max_accepted_payout)) === 0;
@ -108,7 +110,7 @@ export const parseComments = async (comments, currentUserName) => {
comment.author_reputation = getReputation(get(comment, 'author_reputation'));
comment.avatar = getResizedAvatar(get(comment, 'author'));
comment.markdownBody = get(comment, 'body');
comment.body = renderPostBody(comment);
comment.body = renderPostBody(comment, true, webp);
comment.active_votes = activeVotes;
comment.vote_count = activeVotes && activeVotes.length;

View File

@ -718,10 +718,10 @@
verror "^1.10.0"
whatwg-fetch "^2.0.3"
"@esteemapp/esteem-render-helpers@^1.5.6":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@esteemapp/esteem-render-helpers/-/esteem-render-helpers-1.5.6.tgz#fda35a6052e99e059ae786c4cb6c6afb0c5b5f24"
integrity sha512-uK0Nj1ps8vVBgw39B1lPaRSqXXabwOxIhSbnYyuetOCZVzyKKV//ye3WvblADRyuAUjTve5UZCNTQ1MMBY9f0w==
"@esteemapp/esteem-render-helpers@^1.5.9":
version "1.5.9"
resolved "https://registry.yarnpkg.com/@esteemapp/esteem-render-helpers/-/esteem-render-helpers-1.5.9.tgz#c870322d7b1085f89c648061c1b5d241bb056ac9"
integrity sha512-0cA6KLoNhjA7UbiwoaUhYz6ZGz6vPSWrZGc4KTa0SB2Vq6TS9Ac37iGyiLtuF0YeWR66xapi8TOzqR++iYqnew==
dependencies:
he "^1.2.0"
lru-cache "^5.1.1"