mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-25 06:13:12 +03:00
Merge pull request #1499 from esteemapp/comment-depth
WIP Comment links, image, video clicks
This commit is contained in:
commit
c8a33c799e
Binary file not shown.
@ -53,7 +53,7 @@
|
||||
"react-intl": "^3.9.2",
|
||||
"react-native": "0.61.5",
|
||||
"react-native-actionsheet": "esteemapp/react-native-actionsheet",
|
||||
"react-native-autoheight-webview": "^1.3.4",
|
||||
"react-native-autoheight-webview": "^1.4.0",
|
||||
"react-native-code-push": "esteemapp/react-native-code-push",
|
||||
"react-native-config": "luggit/react-native-config#master",
|
||||
"react-native-dark-mode": "^0.2.1",
|
||||
|
@ -99,13 +99,29 @@ const CommentBody = ({
|
||||
|
||||
const __handleBrowserLink = async url => {
|
||||
if (url) {
|
||||
Linking.canOpenURL(url).then(supported => {
|
||||
if (supported) {
|
||||
Linking.openURL(url);
|
||||
} else {
|
||||
Alert.alert(intl.formatMessage({ id: 'alert.failed_to_open' }));
|
||||
}
|
||||
});
|
||||
Alert.alert(
|
||||
intl.formatMessage({ id: 'alert.warning' }),
|
||||
intl.formatMessage({ id: 'alert.external_link' }),
|
||||
[
|
||||
{
|
||||
text: 'Cancel',
|
||||
onPress: () => {},
|
||||
style: 'cancel',
|
||||
},
|
||||
{
|
||||
text: 'OK',
|
||||
onPress: () => {
|
||||
Linking.canOpenURL(url).then(supported => {
|
||||
if (supported) {
|
||||
Linking.openURL(url);
|
||||
} else {
|
||||
Alert.alert(intl.formatMessage({ id: 'alert.failed_to_open' }));
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -326,18 +342,18 @@ const CommentBody = ({
|
||||
</Modal>
|
||||
<AutoHeightWebView
|
||||
key={created.toString()}
|
||||
source={{
|
||||
html: html,
|
||||
}}
|
||||
source={{ html }}
|
||||
allowsFullscreenVideo={true}
|
||||
style={{ width: WIDTH - (32 + 34 * (commentDepth % 6)) }}
|
||||
customStyle={customStyle}
|
||||
onMessage={__handleOnLinkPress}
|
||||
renderLoading={() => <CommentPlaceHolder />}
|
||||
customScript={customBodyScript}
|
||||
renderLoading={() => <CommentPlaceHolder />}
|
||||
startInLoadingState={true}
|
||||
onShouldStartLoadWithRequest={false}
|
||||
scrollEnabled={false}
|
||||
scalesPageToFit={false}
|
||||
zoomable={false}
|
||||
/>
|
||||
</Fragment>
|
||||
);
|
||||
|
@ -1,14 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const customBodyScript = `
|
||||
setTimeout(function() {
|
||||
var images = document.getElementsByTagName("IMG");
|
||||
for (i = 0; i < images.length; i++) {
|
||||
var result = {
|
||||
type: 'image',
|
||||
href: images[i].getAttribute("src") || ''
|
||||
}
|
||||
// workaround
|
||||
var resultStr = JSON.stringify(JSON.stringify(result));
|
||||
|
||||
var message = 'window.ReactNativeWebView.postMessage(' + resultStr + ')';
|
||||
@ -17,9 +15,7 @@ for (i = 0; i < images.length; i++) {
|
||||
}
|
||||
}
|
||||
document.addEventListener('click', function(event) {
|
||||
//event.preventDefault();
|
||||
var el = event.target;
|
||||
// A element can be wrapped with inline element. Look parent elements.
|
||||
while (el.tagName !== 'A') {
|
||||
if (!el.parentNode) {
|
||||
break;
|
||||
@ -119,7 +115,6 @@ document.addEventListener('click', function(event) {
|
||||
var author = el.getAttribute('data-author').toString();
|
||||
window.ReactNativeWebView.postMessage(JSON.stringify(author));
|
||||
})
|
||||
}, 300);
|
||||
true;
|
||||
`;
|
||||
|
||||
|
@ -96,13 +96,29 @@ const PostBody = ({
|
||||
|
||||
const _handleBrowserLink = async url => {
|
||||
if (url) {
|
||||
Linking.canOpenURL(url).then(supported => {
|
||||
if (supported) {
|
||||
Linking.openURL(url);
|
||||
} else {
|
||||
Alert.alert(intl.formatMessage({ id: 'alert.failed_to_open' }));
|
||||
}
|
||||
});
|
||||
Alert.alert(
|
||||
intl.formatMessage({ id: 'alert.warning' }),
|
||||
intl.formatMessage({ id: 'alert.external_link' }),
|
||||
[
|
||||
{
|
||||
text: 'Cancel',
|
||||
onPress: () => {},
|
||||
style: 'cancel',
|
||||
},
|
||||
{
|
||||
text: 'OK',
|
||||
onPress: () => {
|
||||
Linking.canOpenURL(url).then(supported => {
|
||||
if (supported) {
|
||||
Linking.openURL(url);
|
||||
} else {
|
||||
Alert.alert(intl.formatMessage({ id: 'alert.failed_to_open' }));
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -330,6 +346,8 @@ const PostBody = ({
|
||||
startInLoadingState={true}
|
||||
onShouldStartLoadWithRequest={false}
|
||||
scrollEnabled={false}
|
||||
scalesPageToFit={false}
|
||||
zoomable={false}
|
||||
/>
|
||||
</Fragment>
|
||||
);
|
||||
|
@ -280,6 +280,7 @@
|
||||
"success_moved": "Moved to draft",
|
||||
"permission_denied": "Permission denied",
|
||||
"permission_text": "Please, go to phone Settings and change eSteem app permissions.",
|
||||
"key_warning": "Check private key permission!",
|
||||
"success_rebloged": "Reblogged!",
|
||||
"already_rebloged": "You have already reblogged!",
|
||||
"success_favorite": "Favorite added!",
|
||||
@ -303,10 +304,11 @@
|
||||
"same_user": "This user already added to list",
|
||||
"unknow_error": "An error occurred",
|
||||
"error": "Error",
|
||||
"fetch_error": "Fetching data failed, please try again or notify us at info@esteem.app",
|
||||
"fetch_error": "Connection issue, please try again or write to support@esteem.app",
|
||||
"connection_fail": "Connection Failed!",
|
||||
"connection_success": "Successfully connected!",
|
||||
"checking": "Checking...",
|
||||
"external_link": "Are you sure, you want to open an external link?",
|
||||
"not_existing_post": "The post does not exist! Please check permlink and author.",
|
||||
"google_play_version": "We noticed that your device has old version of Google Play. Please update Google Play services and try again!"
|
||||
},
|
||||
@ -354,7 +356,7 @@
|
||||
"invalid_username": "Invalid username, please check and try again",
|
||||
"already_logged": "You are already logged in, please try to add another account",
|
||||
"invalid_credentials": "Invalid credentials, please check and try again",
|
||||
"unknow_error": "Unknown error, please contact us at support@esteem.app"
|
||||
"unknow_error": "Unknown error, please write to support@esteem.app"
|
||||
},
|
||||
"payout": {
|
||||
"potential_payout": "Potential Payout",
|
||||
|
@ -119,7 +119,7 @@ class InAppPurchaseContainer extends Component {
|
||||
} catch (err) {
|
||||
bugsnag.notify(err);
|
||||
Alert.alert(
|
||||
`Fetching data from server failed, please try again or notify us at info@esteem.app
|
||||
`InApp - Connection issue, try again or write to support@esteem.app
|
||||
${err.message.substr(0, 20)}`,
|
||||
);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ const PointsContainer = ({
|
||||
.catch(error => {
|
||||
if (error) {
|
||||
Alert.alert(
|
||||
`Fetching failed, please try again or notify us at info@esteem.app \n${error.message.substr(
|
||||
`PointsClaim - Connection issue, try again or write to support@esteem.app \n${error.message.substr(
|
||||
0,
|
||||
20,
|
||||
)}`,
|
||||
@ -203,7 +203,7 @@ const PointsContainer = ({
|
||||
.catch(error => {
|
||||
if (error) {
|
||||
setIsLoading(false);
|
||||
dispatch(toastNotification(intl.formatMessage({ id: 'alert.fail' })));
|
||||
dispatch(toastNotification(intl.formatMessage({ id: 'alert.key_warning' })));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -80,7 +80,7 @@ class RedeemContainer extends Component {
|
||||
})
|
||||
.catch(error => {
|
||||
if (error) {
|
||||
dispatch(toastNotification(intl.formatMessage({ id: 'alert.fail' })));
|
||||
dispatch(toastNotification(intl.formatMessage({ id: 'alert.key_warning' })));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -281,7 +281,7 @@ export const ignoreUser = async (currentAccount, pin, data) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -514,7 +514,7 @@ const _vote = async (currentAccount, pin, author, permlink, weight) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -562,7 +562,7 @@ export const transferToken = (currentAccount, pin, data) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const transferToSavings = (currentAccount, pin, data) => {
|
||||
@ -596,7 +596,7 @@ export const transferToSavings = (currentAccount, pin, data) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const transferFromSavings = (currentAccount, pin, data) => {
|
||||
@ -630,7 +630,7 @@ export const transferFromSavings = (currentAccount, pin, data) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const transferToVesting = (currentAccount, pin, data) => {
|
||||
@ -662,7 +662,7 @@ export const transferToVesting = (currentAccount, pin, data) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const withdrawVesting = (currentAccount, pin, data) => {
|
||||
@ -693,7 +693,7 @@ export const withdrawVesting = (currentAccount, pin, data) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const delegateVestingShares = (currentAccount, pin, data) => {
|
||||
@ -725,7 +725,7 @@ export const delegateVestingShares = (currentAccount, pin, data) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const setWithdrawVestingRoute = (currentAccount, pin, data) => {
|
||||
@ -758,7 +758,7 @@ export const setWithdrawVestingRoute = (currentAccount, pin, data) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const getWithdrawRoutes = account =>
|
||||
@ -805,7 +805,7 @@ export const followUser = async (currentAccount, pin, data) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const unfollowUser = async (currentAccount, pin, data) => {
|
||||
@ -850,7 +850,7 @@ export const unfollowUser = async (currentAccount, pin, data) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const lookupAccounts = async username => {
|
||||
@ -1014,7 +1014,7 @@ const _postContent = async (
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
// Re-blog
|
||||
@ -1061,7 +1061,7 @@ const _reblog = async (account, pinCode, author, permlink) => {
|
||||
return client.broadcast.json(json, privateKey);
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const claimRewardBalance = (account, pinCode, rewardSteem, rewardSbd, rewardVests) => {
|
||||
@ -1095,7 +1095,7 @@ export const claimRewardBalance = (account, pinCode, rewardSteem, rewardSbd, rew
|
||||
return client.broadcast.sendOperations(opArray, privateKey);
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const transferPoint = (currentAccount, pinCode, data) => {
|
||||
@ -1123,7 +1123,7 @@ export const transferPoint = (currentAccount, pinCode, data) => {
|
||||
return client.broadcast.json(op, privateKey);
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const promote = (currentAccount, pinCode, duration, permlink, author) => {
|
||||
@ -1149,7 +1149,7 @@ export const promote = (currentAccount, pinCode, duration, permlink, author) =>
|
||||
return client.broadcast.json(json, privateKey);
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const boost = (currentAccount, pinCode, point, permlink, author) => {
|
||||
@ -1175,7 +1175,74 @@ export const boost = (currentAccount, pinCode, point, permlink, author) => {
|
||||
return client.broadcast.json(json, privateKey);
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const grantPostingPermission = async (json, pin, currentAccount) => {
|
||||
const digitPinCode = getDigitPinCode(pin);
|
||||
const key = getActiveKey(get(currentAccount, 'local'), digitPinCode);
|
||||
|
||||
const newPosting = Object.assign(
|
||||
{},
|
||||
{ ...get(currentAccount, 'posting') },
|
||||
{
|
||||
account_auths: [
|
||||
...get(currentAccount, 'posting.account_auths'),
|
||||
['esteemapp', get(currentAccount, 'posting.weight_threshold')],
|
||||
],
|
||||
},
|
||||
);
|
||||
newPosting.account_auths.sort();
|
||||
if (get(currentAccount, 'local.authType') === AUTH_TYPE.STEEM_CONNECT) {
|
||||
const token = decryptKey(get(currentAccount, 'local.accessToken'), digitPinCode);
|
||||
const api = new steemconnect.Client({
|
||||
accessToken: token,
|
||||
});
|
||||
const _params = {
|
||||
account: get(currentAccount, 'name'),
|
||||
posting: newPosting,
|
||||
memo_key: get(currentAccount, 'memo_key'),
|
||||
json_metadata: json,
|
||||
};
|
||||
|
||||
const opArray = [['account_update', _params]];
|
||||
|
||||
return api
|
||||
.broadcast(opArray)
|
||||
.then(resp => resp.result)
|
||||
.catch(error => console.log(error));
|
||||
}
|
||||
|
||||
if (key) {
|
||||
const opArray = [
|
||||
[
|
||||
'account_update',
|
||||
{
|
||||
account: get(currentAccount, 'name'),
|
||||
memo_key: get(currentAccount, 'memo_key'),
|
||||
json_metadata: json,
|
||||
posting: newPosting,
|
||||
},
|
||||
],
|
||||
];
|
||||
const privateKey = PrivateKey.fromString(key);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
client.broadcast
|
||||
.sendOperations(opArray, privateKey)
|
||||
.then(result => {
|
||||
resolve(result);
|
||||
})
|
||||
.catch(error => {
|
||||
if (get(error, 'jse_info.code') === 4030100) {
|
||||
error.message = getDsteemDateErrorMessage(error);
|
||||
}
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
export const profileUpdate = async (params, pin, currentAccount) => {
|
||||
@ -1231,7 +1298,7 @@ export const profileUpdate = async (params, pin, currentAccount) => {
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Private key permission issue!'));
|
||||
return Promise.reject(new Error('Check private key permission!'));
|
||||
};
|
||||
|
||||
// HELPERS
|
||||
|
@ -10,7 +10,7 @@ import AsyncStorage from '@react-native-community/async-storage';
|
||||
import { Buffer } from 'buffer';
|
||||
import { uploadImage, addDraft, updateDraft, schedule } from '../../../providers/esteem/esteem';
|
||||
import { toastNotification } from '../../../redux/actions/uiAction';
|
||||
import { postContent, getPurePost } from '../../../providers/steem/dsteem';
|
||||
import { postContent, getPurePost, grantPostingPermission } from '../../../providers/steem/dsteem';
|
||||
import { setDraftPost, getDraftPost } from '../../../realm/realm';
|
||||
|
||||
// Constants
|
||||
@ -449,12 +449,38 @@ class EditorContainer extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
_handleDatePickerChange = (datePickerValue, fields) => {
|
||||
this._submitPost(fields, datePickerValue);
|
||||
_handleDatePickerChange = async (datePickerValue, fields) => {
|
||||
const { currentAccount, pinCode, intl } = this.props;
|
||||
|
||||
const json = get(currentAccount, 'json_metadata', '');
|
||||
|
||||
let hasPostingPerm = false;
|
||||
|
||||
if (currentAccount && currentAccount.posting) {
|
||||
hasPostingPerm =
|
||||
currentAccount.posting.account_auths.filter(x => x[0] === 'esteemapp').length > 0;
|
||||
}
|
||||
|
||||
if (hasPostingPerm) {
|
||||
this._submitPost(fields, datePickerValue);
|
||||
} else {
|
||||
await grantPostingPermission(json, pinCode, currentAccount)
|
||||
.then(() => {
|
||||
this._submitPost(fields, datePickerValue);
|
||||
})
|
||||
.catch(error => {
|
||||
Alert.alert(
|
||||
intl.formatMessage({
|
||||
id: 'alert.fail',
|
||||
}),
|
||||
get(error, 'message', error.toString()),
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_setScheduledPost = data => {
|
||||
const { dispatch, intl } = this.props;
|
||||
const { dispatch, intl, currentAccount, navigation } = this.props;
|
||||
|
||||
schedule(
|
||||
data.author,
|
||||
@ -476,6 +502,13 @@ class EditorContainer extends Component {
|
||||
}),
|
||||
),
|
||||
);
|
||||
setDraftPost({ title: '', body: '', tags: '' }, currentAccount.name);
|
||||
setTimeout(() => {
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.DRAFTS,
|
||||
key: currentAccount.name,
|
||||
});
|
||||
}, 3000);
|
||||
})
|
||||
.catch(() => {
|
||||
this.setState({ isPostSending: false });
|
||||
|
@ -36,7 +36,7 @@ const ReblogScreen = ({ navigation }) => {
|
||||
return (
|
||||
<AccountListContainer data={activeVotes} navigation={navigation}>
|
||||
{({ data, filterResult, handleSearch, handleOnUserPress }) => (
|
||||
<SafeAreaView style={globalStyles.container}>
|
||||
<SafeAreaView style={[globalStyles.container, { paddingBottom: 40 }]}>
|
||||
<BasicHeader
|
||||
title={`${headerTitle} (${data && data.length})`}
|
||||
isHasSearch
|
||||
|
@ -7562,6 +7562,13 @@ react-native-autoheight-webview@^1.3.4:
|
||||
dependencies:
|
||||
prop-types "^15.7.2"
|
||||
|
||||
react-native-autoheight-webview@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-autoheight-webview/-/react-native-autoheight-webview-1.4.0.tgz#03274b8cd5d2e4fdf25511f10cfe3321864460a0"
|
||||
integrity sha512-JhyzEL5eAKPN2VtbA6kL6f3Zphmmx1XcEnIluE+Fed3iwQxXJ1GwrvQb+ENGTZhDKtTdh39sfqadpm+2/h9V0A==
|
||||
dependencies:
|
||||
prop-types "^15.7.2"
|
||||
|
||||
react-native-code-push@esteemapp/react-native-code-push:
|
||||
version "1000.0.0-beta"
|
||||
resolved "https://codeload.github.com/esteemapp/react-native-code-push/tar.gz/c07b7023c1212dc5d9231a0526a869d2501cb221"
|
||||
|
Loading…
Reference in New Issue
Block a user