mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-21 20:31:37 +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);
|
||||||
|
@ -175,7 +175,7 @@ class ApplicationContainer extends Component {
|
|||||||
|
|
||||||
await getAuthStatus().then((res) => {
|
await getAuthStatus().then((res) => {
|
||||||
({ currentUsername } = res);
|
({ currentUsername } = res);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
getUserData().then(async (userData) => {
|
getUserData().then(async (userData) => {
|
||||||
if (userData.length > 0) {
|
if (userData.length > 0) {
|
||||||
|
@ -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' },
|
||||||
]
|
],
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,11 +84,11 @@ export const makeJsonMetadataReply = tags => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const makeJsonMetadata = (meta, tags) => Object.assign({}, meta, {
|
export const makeJsonMetadata = (meta, tags) => Object.assign({}, meta, {
|
||||||
tags,
|
tags,
|
||||||
app: 'esteem/2.0.0-mobile',
|
app: 'esteem/2.0.0-mobile',
|
||||||
format: 'markdown+html',
|
format: 'markdown+html',
|
||||||
community: 'esteem.app',
|
community: 'esteem.app',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const extractMetadata = (body) => {
|
export const extractMetadata = (body) => {
|
||||||
const urlReg = /(\b(https?|ftp):\/\/[A-Z0-9+&@#/%?=~_|!:,.;-]*[-A-Z0-9+&@#/%=~_|])/gim;
|
const urlReg = /(\b(https?|ftp):\/\/[A-Z0-9+&@#/%?=~_|!:,.;-]*[-A-Z0-9+&@#/%=~_|])/gim;
|
||||||
|
@ -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,192 +95,178 @@ 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('>', '');
|
const tag2 = tag.trim().substring(1);
|
||||||
const tag2 = tag.trim().substring(1);
|
const tagLower = tag2.toLowerCase();
|
||||||
const tagLower = tag2.toLowerCase();
|
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);
|
|
||||||
|
|
||||||
if (execLink[2] && execLink[3]) {
|
if (execLink[2] && execLink[3]) {
|
||||||
const embedLink = `https://emb.d.tube/#!/${execLink[2]}/${execLink[3]}`;
|
const embedLink = `https://emb.d.tube/#!/${execLink[2]}/${execLink[3]}`;
|
||||||
|
|
||||||
return iframeBody(embedLink);
|
|
||||||
}
|
|
||||||
if (dTubeMatch) {
|
|
||||||
return iframeBody(dTubeMatch);
|
|
||||||
}
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (imgRegex.test(link)) {
|
|
||||||
const imgMatch = link.match(imgRegex)[0];
|
|
||||||
|
|
||||||
if (imgMatch) return `<a src="${imgMatch}">Image</a>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return link;
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleHTag = input => input.replace(hTagRegex, tag => `<div>${tag}</div>`);
|
|
||||||
|
|
||||||
const handleMarkdownLink = input =>
|
|
||||||
input.replace(copiedPostRegex, link => {
|
|
||||||
const postMatch = link.match(copiedPostRegex);
|
|
||||||
|
|
||||||
if (postMatch) {
|
|
||||||
let tag = postMatch[1];
|
|
||||||
|
|
||||||
if (tag === '/busy.org') {
|
|
||||||
tag = 'busy';
|
|
||||||
}
|
|
||||||
|
|
||||||
const _permlink =
|
|
||||||
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(
|
|
||||||
'@',
|
|
||||||
'',
|
|
||||||
)}">/${_permlink}</a>`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleLinks = input =>
|
|
||||||
input.replace(linkRegex, link => {
|
|
||||||
if (link) {
|
|
||||||
if (
|
|
||||||
link
|
|
||||||
.toLowerCase()
|
|
||||||
.trim()
|
|
||||||
.indexOf('https://steemitimages.com/0x0/') === 0 ||
|
|
||||||
imgRegex.test(link)
|
|
||||||
) {
|
|
||||||
const imageMatch = link.match(imgRegex);
|
|
||||||
|
|
||||||
if (imageMatch) {
|
|
||||||
if (imageMatch[0].indexOf('.gif') > 0) {
|
|
||||||
return gifBody(imageMatch[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (imageMatch[0]) {
|
|
||||||
return imageBody(imageMatch[0]);
|
|
||||||
}
|
|
||||||
} else if (link.trim().indexOf('ipfs.busy.org') > 0) {
|
|
||||||
return imageBody(link);
|
|
||||||
}
|
|
||||||
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
if (link.trim().indexOf('ipfs.busy.org') > 0) {
|
|
||||||
return imageBody(link);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (imgRegex.test(link)) {
|
|
||||||
return imageBody(link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return link;
|
|
||||||
});
|
|
||||||
|
|
||||||
const changeMarkdownImage = input =>
|
|
||||||
input.replace(markdownImageRegex, link => {
|
|
||||||
const markdownMatch = link.match(markdownImageRegex);
|
|
||||||
if (markdownMatch[0]) {
|
|
||||||
const firstMarkdownMatch = markdownMatch[0];
|
|
||||||
const _link = firstMarkdownMatch.match(urlRegex)[0];
|
|
||||||
|
|
||||||
return _link;
|
|
||||||
}
|
|
||||||
return link;
|
|
||||||
});
|
|
||||||
|
|
||||||
const centerStyling = input =>
|
|
||||||
input.replace(
|
|
||||||
centerRegex,
|
|
||||||
() => '<center style="text-align: center; align-items: center; justify-content: center;">',
|
|
||||||
);
|
|
||||||
|
|
||||||
const steemitUrlHandle = input =>
|
|
||||||
input.replace(postRegex, link => {
|
|
||||||
const postMatch = link.match(postRegex);
|
|
||||||
const tag = postMatch[2];
|
|
||||||
const author = postMatch[3].replace('@', '');
|
|
||||||
const permlink = postMatch[4];
|
|
||||||
|
|
||||||
return `<a class="markdown-post-link" href="${permlink}" data_tag={${tag}} data_author="${author}">/${permlink}</a>`;
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleImageTag = input =>
|
|
||||||
input.replace(imgTagRegex, imgTag => {
|
|
||||||
const _imgTag = imgTag.trim();
|
|
||||||
const match = _imgTag.match(imgRegex);
|
|
||||||
|
|
||||||
if (match && match[0]) {
|
|
||||||
return match[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return imgTag;
|
|
||||||
});
|
|
||||||
|
|
||||||
const createYoutubeIframe = input =>
|
|
||||||
input.replace(youTubeRegex, link => {
|
|
||||||
if (link.indexOf(')') || link.indexOf('(')) {
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
|
|
||||||
const execVideo = youTubeRegex.exec(link);
|
|
||||||
const match = link.match(youTubeRegex);
|
|
||||||
|
|
||||||
if (execVideo[1] && match) {
|
|
||||||
const videoLink = execVideo[1];
|
|
||||||
const embedLink = `https://www.youtube.com/embed/${videoLink}`;
|
|
||||||
|
|
||||||
return iframeBody(embedLink);
|
return iframeBody(embedLink);
|
||||||
}
|
}
|
||||||
|
if (dTubeMatch) {
|
||||||
|
return iframeBody(dTubeMatch);
|
||||||
|
}
|
||||||
return link;
|
return link;
|
||||||
});
|
}
|
||||||
|
|
||||||
const handleIframe = input =>
|
if (imgRegex.test(link)) {
|
||||||
input.replace(iframeRegex, link => {
|
const imgMatch = link.match(imgRegex)[0];
|
||||||
const match = link.match(linkRegex);
|
|
||||||
|
|
||||||
if (match && match[0]) {
|
if (imgMatch) return `<a src="${imgMatch}">Image</a>`;
|
||||||
return iframeBody(match[0]);
|
}
|
||||||
|
|
||||||
|
return link;
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleHTag = input => input.replace(hTagRegex, tag => `<div>${tag}</div>`);
|
||||||
|
|
||||||
|
const handleMarkdownLink = input => input.replace(copiedPostRegex, (link) => {
|
||||||
|
const postMatch = link.match(copiedPostRegex);
|
||||||
|
|
||||||
|
if (postMatch) {
|
||||||
|
let tag = postMatch[1];
|
||||||
|
|
||||||
|
if (tag === '/busy.org') {
|
||||||
|
tag = 'busy';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const _permlink = 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(
|
||||||
|
'@',
|
||||||
|
'',
|
||||||
|
)}">/${_permlink}</a>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleLinks = input => input.replace(linkRegex, (link) => {
|
||||||
|
if (link) {
|
||||||
|
if (
|
||||||
|
link
|
||||||
|
.toLowerCase()
|
||||||
|
.trim()
|
||||||
|
.indexOf('https://steemitimages.com/0x0/') === 0
|
||||||
|
|| imgRegex.test(link)
|
||||||
|
) {
|
||||||
|
const imageMatch = link.match(imgRegex);
|
||||||
|
|
||||||
|
if (imageMatch) {
|
||||||
|
if (imageMatch[0].indexOf('.gif') > 0) {
|
||||||
|
return gifBody(imageMatch[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imageMatch[0]) {
|
||||||
|
return imageBody(imageMatch[0]);
|
||||||
|
}
|
||||||
|
} else if (link.trim().indexOf('ipfs.busy.org') > 0) {
|
||||||
|
return imageBody(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
if (link.trim().indexOf('ipfs.busy.org') > 0) {
|
||||||
|
return imageBody(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imgRegex.test(link)) {
|
||||||
|
return imageBody(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return link;
|
||||||
|
});
|
||||||
|
|
||||||
|
const changeMarkdownImage = input => input.replace(markdownImageRegex, (link) => {
|
||||||
|
const markdownMatch = link.match(markdownImageRegex);
|
||||||
|
if (markdownMatch[0]) {
|
||||||
|
const firstMarkdownMatch = markdownMatch[0];
|
||||||
|
const _link = firstMarkdownMatch.match(urlRegex)[0];
|
||||||
|
|
||||||
|
return _link;
|
||||||
|
}
|
||||||
|
return link;
|
||||||
|
});
|
||||||
|
|
||||||
|
const centerStyling = input => input.replace(
|
||||||
|
centerRegex,
|
||||||
|
() => '<center style="text-align: center; align-items: center; justify-content: center;">',
|
||||||
|
);
|
||||||
|
|
||||||
|
const steemitUrlHandle = input => input.replace(postRegex, (link) => {
|
||||||
|
const postMatch = link.match(postRegex);
|
||||||
|
const tag = postMatch[2];
|
||||||
|
const author = postMatch[3].replace('@', '');
|
||||||
|
const permlink = postMatch[4];
|
||||||
|
|
||||||
|
return `<a class="markdown-post-link" href="${permlink}" data_tag={${tag}} data_author="${author}">/${permlink}</a>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleImageTag = input => input.replace(imgTagRegex, (imgTag) => {
|
||||||
|
const _imgTag = imgTag.trim();
|
||||||
|
const match = _imgTag.match(imgRegex);
|
||||||
|
|
||||||
|
if (match && match[0]) {
|
||||||
|
return match[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return imgTag;
|
||||||
|
});
|
||||||
|
|
||||||
|
const createYoutubeIframe = input => input.replace(youTubeRegex, (link) => {
|
||||||
|
if (link.indexOf(')') || link.indexOf('(')) {
|
||||||
return link;
|
return link;
|
||||||
});
|
}
|
||||||
|
|
||||||
const createVimeoIframe = input =>
|
const execVideo = youTubeRegex.exec(link);
|
||||||
input.replace(vimeoRegex, link => {
|
const match = link.match(youTubeRegex);
|
||||||
const execLink = vimeoRegex.exec(link);
|
|
||||||
|
|
||||||
const embedLink = `https://player.vimeo.com/video/${execLink[3]}`;
|
if (execVideo[1] && match) {
|
||||||
|
const videoLink = execVideo[1];
|
||||||
|
const embedLink = `https://www.youtube.com/embed/${videoLink}`;
|
||||||
|
|
||||||
return iframeBody(embedLink);
|
return iframeBody(embedLink);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
return link;
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleIframe = input => input.replace(iframeRegex, (link) => {
|
||||||
|
const match = link.match(linkRegex);
|
||||||
|
|
||||||
|
if (match && match[0]) {
|
||||||
|
return iframeBody(match[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return link;
|
||||||
|
});
|
||||||
|
|
||||||
|
const createVimeoIframe = input => input.replace(vimeoRegex, (link) => {
|
||||||
|
const execLink = vimeoRegex.exec(link);
|
||||||
|
|
||||||
|
const embedLink = `https://player.vimeo.com/video/${execLink[3]}`;
|
||||||
|
|
||||||
|
return iframeBody(embedLink);
|
||||||
|
});
|
||||||
|
|
||||||
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);
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
import { Linking } from 'react-native';
|
import { Linking } from 'react-native';
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
|
|
||||||
export const sendEmail = async (to, subject, body, options = {}) => {
|
export const sendEmail = async (to, subject, body, options = {}) => {
|
||||||
const { cc, bcc } = options;
|
const { cc, bcc } = options;
|
||||||
|
|
||||||
let url = `mailto:${to}`;
|
let url = `mailto:${to}`;
|
||||||
|
|
||||||
const query = qs.stringify({
|
const query = qs.stringify({
|
||||||
subject,
|
subject,
|
||||||
body,
|
body,
|
||||||
cc,
|
cc,
|
||||||
bcc,
|
bcc,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (query.length) {
|
if (query.length) {
|
||||||
url += `?${query}`;
|
url += `?${query}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const canOpen = await Linking.canOpenURL(url);
|
const canOpen = await Linking.canOpenURL(url);
|
||||||
|
|
||||||
if (!canOpen) {
|
if (!canOpen) {
|
||||||
throw new Error('Provided URL can not be handled');
|
throw new Error('Provided URL can not be handled');
|
||||||
}
|
}
|
||||||
|
|
||||||
return Linking.openURL(url);
|
return Linking.openURL(url);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user