mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-02 11:15:35 +03:00
Merge branch 'development' of https://github.com/ecency/ecency-mobile into development
This commit is contained in:
commit
b99084e7fe
@ -35,7 +35,7 @@
|
|||||||
"@esteemapp/react-native-multi-slider": "^1.1.0",
|
"@esteemapp/react-native-multi-slider": "^1.1.0",
|
||||||
"@esteemapp/react-native-render-html": "^4.1.5",
|
"@esteemapp/react-native-render-html": "^4.1.5",
|
||||||
"@esteemapp/react-native-slider": "^0.12.0",
|
"@esteemapp/react-native-slider": "^0.12.0",
|
||||||
"@hiveio/dhive": "^0.14.16",
|
"@hiveio/dhive": "^1.0.1",
|
||||||
"@react-native-community/async-storage": "^1.11.0",
|
"@react-native-community/async-storage": "^1.11.0",
|
||||||
"@react-native-community/cameraroll": "^1.3.0",
|
"@react-native-community/cameraroll": "^1.3.0",
|
||||||
"@react-native-community/cli-platform-ios": "^4.10.1",
|
"@react-native-community/cli-platform-ios": "^4.10.1",
|
||||||
|
@ -55,7 +55,7 @@ const PostDisplayView = ({
|
|||||||
// Component Life Cycles
|
// Component Life Cycles
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isLoggedIn && get(currentAccount, 'name') && !isNewPost) {
|
if (isLoggedIn && get(currentAccount, 'name') && !isNewPost) {
|
||||||
userActivity(currentAccount.name, 10);
|
userActivity(10);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import { default as ROUTES } from '../../../constants/routeNames';
|
|||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
import styles from './walletHeaderStyles';
|
import styles from './walletHeaderStyles';
|
||||||
|
import { claimPoints } from '../../../providers/ecency/ePoint';
|
||||||
|
|
||||||
const WalletHeaderView = ({
|
const WalletHeaderView = ({
|
||||||
claim,
|
claim,
|
||||||
@ -93,7 +94,9 @@ const WalletHeaderView = ({
|
|||||||
isDisable={isClaiming}
|
isDisable={isClaiming}
|
||||||
style={styles.mainButton}
|
style={styles.mainButton}
|
||||||
height={50}
|
height={50}
|
||||||
onPress={() => (unclaimedBalance ? claim() : navigation.navigate(ROUTES.SCREENS.BOOST))}
|
onPress={() =>
|
||||||
|
unclaimedBalance ? claimPoints() : navigation.navigate(ROUTES.SCREENS.BOOST)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<View style={styles.mainButtonWrapper}>
|
<View style={styles.mainButtonWrapper}>
|
||||||
<Text style={styles.unclaimedText}>
|
<Text style={styles.unclaimedText}>
|
||||||
|
@ -6,7 +6,7 @@ import { useIntl } from 'react-intl';
|
|||||||
import { withNavigation } from 'react-navigation';
|
import { withNavigation } from 'react-navigation';
|
||||||
|
|
||||||
// Services and Actions
|
// Services and Actions
|
||||||
import { getUser, getUserPoints, claim } from '../providers/ecency/ePoint';
|
import { getUser, getUserPoints, claimPoints } from '../providers/ecency/ePoint';
|
||||||
import { openPinCodeModal } from '../redux/actions/applicationActions';
|
import { openPinCodeModal } from '../redux/actions/applicationActions';
|
||||||
import { getAccount, boost } from '../providers/hive/dhive';
|
import { getAccount, boost } from '../providers/hive/dhive';
|
||||||
import { getUserDataWithUsername } from '../realm/realm';
|
import { getUserDataWithUsername } from '../realm/realm';
|
||||||
@ -173,7 +173,7 @@ const PointsContainer = ({
|
|||||||
const _claimPoints = async () => {
|
const _claimPoints = async () => {
|
||||||
setIsClaiming(true);
|
setIsClaiming(true);
|
||||||
|
|
||||||
await claim(username)
|
await claimPoints()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
_fetchUserPointActivities(username);
|
_fetchUserPointActivities(username);
|
||||||
})
|
})
|
||||||
|
@ -1,30 +1,36 @@
|
|||||||
import { Alert } from 'react-native';
|
import { Alert } from 'react-native';
|
||||||
import ePointApi from '../../config/api';
|
import ePointApi from '../../config/api';
|
||||||
import { jsonStringify } from '../../utils/jsonUtils';
|
import ecencyApi from '../../config/ecencyApi';
|
||||||
|
import bugsnagInstance from '../../config/bugsnag';
|
||||||
|
|
||||||
export const userActivity = (us, ty, bl = '', tx = '') =>
|
|
||||||
new Promise((resolve) => {
|
|
||||||
const params = {
|
|
||||||
us,
|
|
||||||
ty,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (bl) {
|
/**
|
||||||
params.bl = bl;
|
* Records user activty and reward poinsts
|
||||||
}
|
* @param ty points
|
||||||
|
* @param bl block number
|
||||||
|
* @param tx transaction id
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export const userActivity = async (ty:number, tx:string = '', bl:string|number = '') => {
|
||||||
|
try{
|
||||||
|
const data: {
|
||||||
|
|
||||||
|
ty: number;
|
||||||
|
bl?: string | number;
|
||||||
|
tx?: string | number;
|
||||||
|
} = {ty};
|
||||||
|
|
||||||
|
if (bl) data.bl = bl;
|
||||||
|
if (tx) data.tx = tx;
|
||||||
|
|
||||||
|
const response = await ecencyApi.post('/private-api/usr-activity', data)
|
||||||
|
return response.data;
|
||||||
|
}catch(error){
|
||||||
|
console.warn("Failed to push user activity point", error);
|
||||||
|
bugsnagInstance.notify(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tx) {
|
|
||||||
params.tx = tx;
|
|
||||||
}
|
|
||||||
ePointApi
|
|
||||||
.post('/usr-activity', params)
|
|
||||||
.then((res) => {
|
|
||||||
resolve(res.data);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
Alert.alert('Error', error.message);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
export const getUser = (username) =>
|
export const getUser = (username) =>
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
@ -50,19 +56,16 @@ export const getUserPoints = (username) =>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export const claim = (username) =>
|
export const claimPoints = async () => {
|
||||||
new Promise((resolve, reject) => {
|
try{
|
||||||
ePointApi
|
const response = await ecencyApi.post('/private-api/points-claim')
|
||||||
.put('/claim', {
|
return response.data;
|
||||||
us: `${username}`,
|
}catch(error){
|
||||||
})
|
console.warn("Failed to calim points", error);
|
||||||
.then((res) => {
|
bugsnagInstance.notify(error)
|
||||||
resolve(res.data);
|
}
|
||||||
})
|
}
|
||||||
.catch((error) => {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
export const gameStatusCheck = (username, type) =>
|
export const gameStatusCheck = (username, type) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
@ -634,20 +634,41 @@ export const signImage = async (file, currentAccount, pin) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method getBlockNum return block num based on transaction id
|
||||||
|
* @param trx_id transactionId
|
||||||
|
*/
|
||||||
|
const getBlockNum = async (trx_id) => {
|
||||||
|
try {
|
||||||
|
console.log('Getting transaction data', trx_id);
|
||||||
|
const transData = await client.call('condenser_api', 'get_transaction', [trx_id]);
|
||||||
|
const blockNum = transData.block_num;
|
||||||
|
console.log('Block number', blockNum);
|
||||||
|
return blockNum;
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('Failed to get transaction data: ', err);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method upvote upvote a content
|
* @method upvote upvote a content
|
||||||
* @param vote vote object(author, permlink, voter, weight)
|
* @param vote vote object(author, permlink, voter, weight)
|
||||||
* @param postingKey private posting key
|
* @param postingKey private posting key
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const vote = (account, pin, author, permlink, weight) =>
|
export const vote = async (account, pin, author, permlink, weight) => {
|
||||||
_vote(account, pin, author, permlink, weight).then((resp) => {
|
try {
|
||||||
userActivity(account.username, 120, resp.block_num, resp.id);
|
const resp = await _vote(account, pin, author, permlink, weight);
|
||||||
|
userActivity(120, resp.id);
|
||||||
console.log('Returning vote response');
|
console.log('Returning vote response');
|
||||||
return resp;
|
return resp;
|
||||||
});
|
} catch (err) {
|
||||||
|
console.warn('Failed to complete vote');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const _vote = async (currentAccount, pin, author, permlink, weight) => {
|
const _vote = (currentAccount, pin, author, permlink, weight) => {
|
||||||
const digitPinCode = getDigitPinCode(pin);
|
const digitPinCode = getDigitPinCode(pin);
|
||||||
const key = getAnyPrivateKey(currentAccount.local, digitPinCode);
|
const key = getAnyPrivateKey(currentAccount.local, digitPinCode);
|
||||||
if (currentAccount.local.authType === AUTH_TYPE.STEEM_CONNECT) {
|
if (currentAccount.local.authType === AUTH_TYPE.STEEM_CONNECT) {
|
||||||
@ -1177,9 +1198,9 @@ export const postContent = (
|
|||||||
voteWeight,
|
voteWeight,
|
||||||
).then((resp) => {
|
).then((resp) => {
|
||||||
const t = title ? 100 : 110;
|
const t = title ? 100 : 110;
|
||||||
const { block_num, id } = resp;
|
const { id } = resp;
|
||||||
if (!isEdit) {
|
if (!isEdit) {
|
||||||
userActivity(account.username, t, block_num, id);
|
userActivity(t, id);
|
||||||
}
|
}
|
||||||
return resp;
|
return resp;
|
||||||
});
|
});
|
||||||
@ -1303,7 +1324,7 @@ const _postContent = async (
|
|||||||
// TODO: remove pinCode
|
// TODO: remove pinCode
|
||||||
export const reblog = (account, pinCode, author, permlink) =>
|
export const reblog = (account, pinCode, author, permlink) =>
|
||||||
_reblog(account, pinCode, author, permlink).then((resp) => {
|
_reblog(account, pinCode, author, permlink).then((resp) => {
|
||||||
userActivity(account.name, 130, resp.block_num, resp.id);
|
userActivity(130, resp.id);
|
||||||
return resp;
|
return resp;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class LoginContainer extends PureComponent {
|
|||||||
dispatch(setInitPosts([]));
|
dispatch(setInitPosts([]));
|
||||||
dispatch(setFeedPosts([]));
|
dispatch(setFeedPosts([]));
|
||||||
|
|
||||||
userActivity(result.name, 20);
|
userActivity(20);
|
||||||
setExistUser(true);
|
setExistUser(true);
|
||||||
this._setPushToken(result.name);
|
this._setPushToken(result.name);
|
||||||
if (isPinCodeOpen) {
|
if (isPinCodeOpen) {
|
||||||
|
@ -1171,10 +1171,10 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@hapi/hoek" "^8.3.0"
|
"@hapi/hoek" "^8.3.0"
|
||||||
|
|
||||||
"@hiveio/dhive@^0.14.16":
|
"@hiveio/dhive@^1.0.1":
|
||||||
version "0.14.16"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/@hiveio/dhive/-/dhive-0.14.16.tgz#03602cda2960e511b328fbea7f82aa3e99ce35b7"
|
resolved "https://registry.yarnpkg.com/@hiveio/dhive/-/dhive-1.0.1.tgz#76bb9e9dbd4cc9efadafd8a40b7025c997a56aba"
|
||||||
integrity sha512-HTNwzfJHGLaAEXsLP82OG7U2s57wXwRgfL6QXhgGpLfkBKIEwgsDchB088X4vS0GfmL5RrMyLDXGrWyzwgSCNw==
|
integrity sha512-j6PEAhLwhSWzMjQiPS0Qsy3jZ+6pAirlnPkgkkb+3q7CGG0eNA7w5VYaFv4OFGecOQfESj7MViYhpzC+5qiq0Q==
|
||||||
dependencies:
|
dependencies:
|
||||||
bs58 "^4.0.1"
|
bs58 "^4.0.1"
|
||||||
bytebuffer "^5.0.1"
|
bytebuffer "^5.0.1"
|
||||||
|
Loading…
Reference in New Issue
Block a user