mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
commit
bfffe0cebe
@ -38,7 +38,7 @@ class PostButtonView extends Component {
|
|||||||
if (this.mode._value) {
|
if (this.mode._value) {
|
||||||
const { routes, isCollapsePostButtonOpen } = this.props;
|
const { routes, isCollapsePostButtonOpen } = this.props;
|
||||||
const nextRouteName = nextProps.routes[0].routes[nextProps.routes[0].routes.length - 1].routeName;
|
const nextRouteName = nextProps.routes[0].routes[nextProps.routes[0].routes.length - 1].routeName;
|
||||||
const routeName = routes[0].routes[routes[0].routes.length - 1].routeName;
|
const { routeName } = routes[0].routes[routes[0].routes.length - 1];
|
||||||
const { isCollapse } = this.state;
|
const { isCollapse } = this.state;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -35,7 +35,7 @@ class PostButtonsForAndroid extends Component {
|
|||||||
// For closing sub buttons
|
// For closing sub buttons
|
||||||
const { routes, isCollapsePostButtonOpen } = this.props;
|
const { routes, isCollapsePostButtonOpen } = this.props;
|
||||||
const nextRouteName = nextProps.routes[0].routes[nextProps.routes[0].routes.length - 1].routeName;
|
const nextRouteName = nextProps.routes[0].routes[nextProps.routes[0].routes.length - 1].routeName;
|
||||||
const routeName = routes[0].routes[routes[0].routes.length - 1].routeName;
|
const { routeName } = routes[0].routes[routes[0].routes.length - 1];
|
||||||
const { isCollapse } = this.state;
|
const { isCollapse } = this.state;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -32,7 +32,7 @@ class PostHeaderDescription extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Component Functions
|
// Component Functions
|
||||||
_handleOnUserPress = username => {
|
_handleOnUserPress = (username) => {
|
||||||
const { navigation, profileOnPress, reputation } = this.props;
|
const { navigation, profileOnPress, reputation } = this.props;
|
||||||
|
|
||||||
if (profileOnPress) {
|
if (profileOnPress) {
|
||||||
|
@ -189,7 +189,7 @@ export const updateUserData = userData => new Promise((resolve, reject) => {
|
|||||||
|
|
||||||
export const removeUserData = username => new Promise((resolve, reject) => {
|
export const removeUserData = username => new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const account = realm.objects(USER_SCHEMA).filtered('username = $0', username)
|
const account = realm.objects(USER_SCHEMA).filtered('username = $0', username);
|
||||||
if (Array.from(account).length > 0) {
|
if (Array.from(account).length > 0) {
|
||||||
realm.write(() => {
|
realm.write(() => {
|
||||||
realm.delete(account);
|
realm.delete(account);
|
||||||
|
@ -42,7 +42,9 @@ class ApplicationScreen extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { isConnected, isDarkTheme, locale, toastNotification } = this.props;
|
const {
|
||||||
|
isConnected, isDarkTheme, locale, toastNotification,
|
||||||
|
} = this.props;
|
||||||
const { isShowToastNotification } = this.state;
|
const { isShowToastNotification } = this.state;
|
||||||
const barStyle = isDarkTheme ? 'light-content' : 'dark-content';
|
const barStyle = isDarkTheme ? 'light-content' : 'dark-content';
|
||||||
const barColor = isDarkTheme ? '#1e2835' : '#fff';
|
const barColor = isDarkTheme ? '#1e2835' : '#fff';
|
||||||
|
@ -2,6 +2,7 @@ import React, { Component } from 'react';
|
|||||||
import { injectIntl } from 'react-intl';
|
import { injectIntl } from 'react-intl';
|
||||||
import { View, FlatList, Text } from 'react-native';
|
import { View, FlatList, Text } from 'react-native';
|
||||||
import ScrollableTabView from '@esteemapp/react-native-scrollable-tab-view';
|
import ScrollableTabView from '@esteemapp/react-native-scrollable-tab-view';
|
||||||
|
import ActionSheet from 'react-native-actionsheet';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { getPostSummary } from '../../../utils/formatter';
|
import { getPostSummary } from '../../../utils/formatter';
|
||||||
@ -13,7 +14,6 @@ import { BasicHeader } from '../../../components/basicHeader';
|
|||||||
import { PostListItem } from '../../../components/postListItem';
|
import { PostListItem } from '../../../components/postListItem';
|
||||||
import { PostCardPlaceHolder } from '../../../components/basicUIElements';
|
import { PostCardPlaceHolder } from '../../../components/basicUIElements';
|
||||||
import { TabBar } from '../../../components/tabBar';
|
import { TabBar } from '../../../components/tabBar';
|
||||||
import ActionSheet from 'react-native-actionsheet';
|
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
import globalStyles from '../../../globalStyles';
|
import globalStyles from '../../../globalStyles';
|
||||||
@ -29,7 +29,7 @@ class DraftsScreen extends Component {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
selectedId: null,
|
selectedId: null,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component Life Cycles
|
// Component Life Cycles
|
||||||
@ -56,7 +56,7 @@ class DraftsScreen extends Component {
|
|||||||
image={image ? { uri: catchDraftImage(item.body) } : null}
|
image={image ? { uri: catchDraftImage(item.body) } : null}
|
||||||
username={currentAccount.name}
|
username={currentAccount.name}
|
||||||
reputation={currentAccount.reputation}
|
reputation={currentAccount.reputation}
|
||||||
handleOnPressItem={() => isSchedules ? this.setState({selectedId: item._id}, () => this.ActionSheet.show()) : editDraft}
|
handleOnPressItem={() => (isSchedules ? this.setState({ selectedId: item._id }, () => this.ActionSheet.show()) : editDraft)}
|
||||||
handleOnRemoveItem={isSchedules ? removeSchedule : removeDraft}
|
handleOnRemoveItem={isSchedules ? removeSchedule : removeDraft}
|
||||||
id={item._id}
|
id={item._id}
|
||||||
key={item._id}
|
key={item._id}
|
||||||
@ -97,7 +97,9 @@ class DraftsScreen extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { drafts, schedules, intl, moveScheduleToDraft } = this.props;
|
const {
|
||||||
|
drafts, schedules, intl, moveScheduleToDraft,
|
||||||
|
} = this.props;
|
||||||
const { selectedId } = this.state;
|
const { selectedId } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -287,7 +287,7 @@ class PinCodeContainer extends Component {
|
|||||||
[
|
[
|
||||||
{ text: intl.formatMessage({ id: 'alert.clear' }), onPress: () => this._forgotPinCode() },
|
{ text: intl.formatMessage({ id: 'alert.clear' }), onPress: () => this._forgotPinCode() },
|
||||||
{ text: intl.formatMessage({ id: 'alert.cancel' }), style: 'destructive' },
|
{ text: intl.formatMessage({ id: 'alert.cancel' }), style: 'destructive' },
|
||||||
]
|
],
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ const imgTagRegex = /(<img[^>]*>)/g;
|
|||||||
const iframeRegex = /(?:<iframe[^>]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/g;
|
const iframeRegex = /(?:<iframe[^>]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/g;
|
||||||
const hTagRegex = /(<h([1-6])>([^<]*)<\/h([1-6])>)/g;
|
const hTagRegex = /(<h([1-6])>([^<]*)<\/h([1-6])>)/g;
|
||||||
|
|
||||||
export const markDown2Html = input => {
|
export const markDown2Html = (input) => {
|
||||||
if (!input) {
|
if (!input) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -95,15 +95,13 @@ export const markDown2Html = input => {
|
|||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
const replaceAuthorNames = input =>
|
const replaceAuthorNames = input => input.replace(authorNameRegex, (match, preceeding1, preceeding2, user) => {
|
||||||
input.replace(authorNameRegex, (match, preceeding1, preceeding2, user) => {
|
|
||||||
const userLower = user.toLowerCase();
|
const userLower = user.toLowerCase();
|
||||||
const preceedings = (preceeding1 || '') + (preceeding2 || '');
|
const preceedings = (preceeding1 || '') + (preceeding2 || '');
|
||||||
return `${preceedings}<a class="markdown-author-link" href="${userLower}" data-author="${userLower}"> @${user}</a>`;
|
return `${preceedings}<a class="markdown-author-link" href="${userLower}" data-author="${userLower}"> @${user}</a>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const replaceTags = input =>
|
const replaceTags = input => input.replace(tagsRegex, (tag) => {
|
||||||
input.replace(tagsRegex, tag => {
|
|
||||||
if (/#[\d]+$/.test(tag)) return tag;
|
if (/#[\d]+$/.test(tag)) return tag;
|
||||||
const preceding = /^\s|>/.test(tag) ? tag[0] : '';
|
const preceding = /^\s|>/.test(tag) ? tag[0] : '';
|
||||||
tag = tag.replace('>', '');
|
tag = tag.replace('>', '');
|
||||||
@ -112,8 +110,7 @@ const replaceTags = input =>
|
|||||||
return `${preceding}<a class="markdown-tag-link" href="${tagLower}" data-tag="${tagLower}">${tag.trim()}</a>`;
|
return `${preceding}<a class="markdown-tag-link" href="${tagLower}" data-tag="${tagLower}">${tag.trim()}</a>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleATag = input =>
|
const handleATag = input => input.replace(aTagRegex, (link) => {
|
||||||
input.replace(aTagRegex, link => {
|
|
||||||
if (dTubeRegex.test(link)) {
|
if (dTubeRegex.test(link)) {
|
||||||
const dTubeMatch = link.match(dTubeRegex)[0];
|
const dTubeMatch = link.match(dTubeRegex)[0];
|
||||||
const execLink = dTubeRegex.exec(dTubeMatch);
|
const execLink = dTubeRegex.exec(dTubeMatch);
|
||||||
@ -140,8 +137,7 @@ const handleATag = input =>
|
|||||||
|
|
||||||
const handleHTag = input => input.replace(hTagRegex, tag => `<div>${tag}</div>`);
|
const handleHTag = input => input.replace(hTagRegex, tag => `<div>${tag}</div>`);
|
||||||
|
|
||||||
const handleMarkdownLink = input =>
|
const handleMarkdownLink = input => input.replace(copiedPostRegex, (link) => {
|
||||||
input.replace(copiedPostRegex, link => {
|
|
||||||
const postMatch = link.match(copiedPostRegex);
|
const postMatch = link.match(copiedPostRegex);
|
||||||
|
|
||||||
if (postMatch) {
|
if (postMatch) {
|
||||||
@ -151,8 +147,7 @@ const handleMarkdownLink = input =>
|
|||||||
tag = 'busy';
|
tag = 'busy';
|
||||||
}
|
}
|
||||||
|
|
||||||
const _permlink =
|
const _permlink = postMatch[3].indexOf(')') > 0 ? postMatch[3].replace(')', '') : postMatch[3];
|
||||||
postMatch[3].indexOf(')') > 0 ? postMatch[3].replace(')', '') : postMatch[3];
|
|
||||||
|
|
||||||
return `<a class="markdown-post-link" href="${_permlink}" data_tag={${tag.trim()}} data_author="${postMatch[2].replace(
|
return `<a class="markdown-post-link" href="${_permlink}" data_tag={${tag.trim()}} data_author="${postMatch[2].replace(
|
||||||
'@',
|
'@',
|
||||||
@ -161,15 +156,14 @@ const handleMarkdownLink = input =>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleLinks = input =>
|
const handleLinks = input => input.replace(linkRegex, (link) => {
|
||||||
input.replace(linkRegex, link => {
|
|
||||||
if (link) {
|
if (link) {
|
||||||
if (
|
if (
|
||||||
link
|
link
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.trim()
|
.trim()
|
||||||
.indexOf('https://steemitimages.com/0x0/') === 0 ||
|
.indexOf('https://steemitimages.com/0x0/') === 0
|
||||||
imgRegex.test(link)
|
|| imgRegex.test(link)
|
||||||
) {
|
) {
|
||||||
const imageMatch = link.match(imgRegex);
|
const imageMatch = link.match(imgRegex);
|
||||||
|
|
||||||
@ -199,8 +193,7 @@ const handleLinks = input =>
|
|||||||
return link;
|
return link;
|
||||||
});
|
});
|
||||||
|
|
||||||
const changeMarkdownImage = input =>
|
const changeMarkdownImage = input => input.replace(markdownImageRegex, (link) => {
|
||||||
input.replace(markdownImageRegex, link => {
|
|
||||||
const markdownMatch = link.match(markdownImageRegex);
|
const markdownMatch = link.match(markdownImageRegex);
|
||||||
if (markdownMatch[0]) {
|
if (markdownMatch[0]) {
|
||||||
const firstMarkdownMatch = markdownMatch[0];
|
const firstMarkdownMatch = markdownMatch[0];
|
||||||
@ -211,14 +204,12 @@ const changeMarkdownImage = input =>
|
|||||||
return link;
|
return link;
|
||||||
});
|
});
|
||||||
|
|
||||||
const centerStyling = input =>
|
const centerStyling = input => input.replace(
|
||||||
input.replace(
|
|
||||||
centerRegex,
|
centerRegex,
|
||||||
() => '<center style="text-align: center; align-items: center; justify-content: center;">',
|
() => '<center style="text-align: center; align-items: center; justify-content: center;">',
|
||||||
);
|
);
|
||||||
|
|
||||||
const steemitUrlHandle = input =>
|
const steemitUrlHandle = input => input.replace(postRegex, (link) => {
|
||||||
input.replace(postRegex, link => {
|
|
||||||
const postMatch = link.match(postRegex);
|
const postMatch = link.match(postRegex);
|
||||||
const tag = postMatch[2];
|
const tag = postMatch[2];
|
||||||
const author = postMatch[3].replace('@', '');
|
const author = postMatch[3].replace('@', '');
|
||||||
@ -227,8 +218,7 @@ const steemitUrlHandle = input =>
|
|||||||
return `<a class="markdown-post-link" href="${permlink}" data_tag={${tag}} data_author="${author}">/${permlink}</a>`;
|
return `<a class="markdown-post-link" href="${permlink}" data_tag={${tag}} data_author="${author}">/${permlink}</a>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleImageTag = input =>
|
const handleImageTag = input => input.replace(imgTagRegex, (imgTag) => {
|
||||||
input.replace(imgTagRegex, imgTag => {
|
|
||||||
const _imgTag = imgTag.trim();
|
const _imgTag = imgTag.trim();
|
||||||
const match = _imgTag.match(imgRegex);
|
const match = _imgTag.match(imgRegex);
|
||||||
|
|
||||||
@ -239,8 +229,7 @@ const handleImageTag = input =>
|
|||||||
return imgTag;
|
return imgTag;
|
||||||
});
|
});
|
||||||
|
|
||||||
const createYoutubeIframe = input =>
|
const createYoutubeIframe = input => input.replace(youTubeRegex, (link) => {
|
||||||
input.replace(youTubeRegex, link => {
|
|
||||||
if (link.indexOf(')') || link.indexOf('(')) {
|
if (link.indexOf(')') || link.indexOf('(')) {
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
@ -258,8 +247,7 @@ const createYoutubeIframe = input =>
|
|||||||
return link;
|
return link;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleIframe = input =>
|
const handleIframe = input => input.replace(iframeRegex, (link) => {
|
||||||
input.replace(iframeRegex, link => {
|
|
||||||
const match = link.match(linkRegex);
|
const match = link.match(linkRegex);
|
||||||
|
|
||||||
if (match && match[0]) {
|
if (match && match[0]) {
|
||||||
@ -269,8 +257,7 @@ const handleIframe = input =>
|
|||||||
return link;
|
return link;
|
||||||
});
|
});
|
||||||
|
|
||||||
const createVimeoIframe = input =>
|
const createVimeoIframe = input => input.replace(vimeoRegex, (link) => {
|
||||||
input.replace(vimeoRegex, link => {
|
|
||||||
const execLink = vimeoRegex.exec(link);
|
const execLink = vimeoRegex.exec(link);
|
||||||
|
|
||||||
const embedLink = `https://player.vimeo.com/video/${execLink[3]}`;
|
const embedLink = `https://player.vimeo.com/video/${execLink[3]}`;
|
||||||
@ -279,8 +266,7 @@ const createVimeoIframe = input =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
const iframeBody = link => `<iframe frameborder='0' allowfullscreen src='${link}'></iframe>`;
|
const iframeBody = link => `<iframe frameborder='0' allowfullscreen src='${link}'></iframe>`;
|
||||||
const imageBody = link =>
|
const imageBody = link => `<center style="text-align: center; align-items: center; justify-content: center;"><img src="${`https://steemitimages.com/600x0/${link}`}" /></center>`;
|
||||||
`<center style="text-align: center; align-items: center; justify-content: center;"><img src="${`https://steemitimages.com/600x0/${link}`}" /></center>`;
|
|
||||||
const gifBody = link => `<img src="${`https://steemitimages.com/0x0/${link}`}" />`;
|
const gifBody = link => `<img src="${`https://steemitimages.com/0x0/${link}`}" />`;
|
||||||
const handleImageLink = input => input.replace(imgRegex, link => imageBody(link));
|
const handleImageLink = input => input.replace(imgRegex, link => imageBody(link));
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@ 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) =>
|
export const parsePosts = (posts, currentUserName) => (
|
||||||
!posts ? null : posts.map(post => parsePost(post, currentUserName));
|
!posts ? null : posts.map(post => parsePost(post, currentUserName))
|
||||||
|
);
|
||||||
|
|
||||||
export const parsePost = (post, currentUserName) => {
|
export const parsePost = (post, currentUserName) => {
|
||||||
if (!post) {
|
if (!post) {
|
||||||
@ -32,10 +33,9 @@ export const parsePost = (post, currentUserName) => {
|
|||||||
post.is_voted = false;
|
post.is_voted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalPayout =
|
const totalPayout = parseFloat(post.pending_payout_value)
|
||||||
parseFloat(post.pending_payout_value) +
|
+ parseFloat(post.total_payout_value)
|
||||||
parseFloat(post.total_payout_value) +
|
+ parseFloat(post.curator_payout_value);
|
||||||
parseFloat(post.curator_payout_value);
|
|
||||||
|
|
||||||
post.total_payout = totalPayout.toFixed(3);
|
post.total_payout = totalPayout.toFixed(3);
|
||||||
|
|
||||||
@ -44,8 +44,7 @@ export const parsePost = (post, currentUserName) => {
|
|||||||
|
|
||||||
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.vote_perecent = post.active_votes[i].voter === currentUserName ? post.active_votes[i].percent : null;
|
||||||
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;
|
||||||
@ -59,8 +58,7 @@ export const parsePost = (post, currentUserName) => {
|
|||||||
return post;
|
return post;
|
||||||
};
|
};
|
||||||
|
|
||||||
const isVoted = (activeVotes, currentUserName) =>
|
const isVoted = (activeVotes, currentUserName) => activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
|
||||||
activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
|
|
||||||
|
|
||||||
const postImage = (metaData, body) => {
|
const postImage = (metaData, body) => {
|
||||||
const imgTagRegex = /(<img[^>]*>)/g;
|
const imgTagRegex = /(<img[^>]*>)/g;
|
||||||
@ -135,8 +133,8 @@ const postImage = (metaData, body) => {
|
|||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
|
|
||||||
export const parseComments = comments => {
|
export const parseComments = (comments) => {
|
||||||
comments.map(comment => {
|
comments.map((comment) => {
|
||||||
comment.pending_payout_value = parseFloat(comment.pending_payout_value).toFixed(3);
|
comment.pending_payout_value = parseFloat(comment.pending_payout_value).toFixed(3);
|
||||||
comment.vote_count = comment.active_votes.length;
|
comment.vote_count = comment.active_votes.length;
|
||||||
comment.author_reputation = getReputation(comment.author_reputation);
|
comment.author_reputation = getReputation(comment.author_reputation);
|
||||||
|
Loading…
Reference in New Issue
Block a user