mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-02 02:07:10 +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-render-html": "^4.1.5",
|
||||
"@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/cameraroll": "^1.3.0",
|
||||
"@react-native-community/cli-platform-ios": "^4.10.1",
|
||||
|
@ -55,7 +55,7 @@ const PostDisplayView = ({
|
||||
// Component Life Cycles
|
||||
useEffect(() => {
|
||||
if (isLoggedIn && get(currentAccount, 'name') && !isNewPost) {
|
||||
userActivity(currentAccount.name, 10);
|
||||
userActivity(10);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
@ -14,6 +14,7 @@ import { default as ROUTES } from '../../../constants/routeNames';
|
||||
|
||||
// Styles
|
||||
import styles from './walletHeaderStyles';
|
||||
import { claimPoints } from '../../../providers/ecency/ePoint';
|
||||
|
||||
const WalletHeaderView = ({
|
||||
claim,
|
||||
@ -93,7 +94,9 @@ const WalletHeaderView = ({
|
||||
isDisable={isClaiming}
|
||||
style={styles.mainButton}
|
||||
height={50}
|
||||
onPress={() => (unclaimedBalance ? claim() : navigation.navigate(ROUTES.SCREENS.BOOST))}
|
||||
onPress={() =>
|
||||
unclaimedBalance ? claimPoints() : navigation.navigate(ROUTES.SCREENS.BOOST)
|
||||
}
|
||||
>
|
||||
<View style={styles.mainButtonWrapper}>
|
||||
<Text style={styles.unclaimedText}>
|
||||
|
@ -6,7 +6,7 @@ import { useIntl } from 'react-intl';
|
||||
import { withNavigation } from 'react-navigation';
|
||||
|
||||
// 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 { getAccount, boost } from '../providers/hive/dhive';
|
||||
import { getUserDataWithUsername } from '../realm/realm';
|
||||
@ -173,7 +173,7 @@ const PointsContainer = ({
|
||||
const _claimPoints = async () => {
|
||||
setIsClaiming(true);
|
||||
|
||||
await claim(username)
|
||||
await claimPoints()
|
||||
.then(() => {
|
||||
_fetchUserPointActivities(username);
|
||||
})
|
||||
|
@ -1,30 +1,36 @@
|
||||
import { Alert } from 'react-native';
|
||||
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) =>
|
||||
new Promise((resolve) => {
|
||||
@ -38,7 +44,7 @@ export const getUser = (username) =>
|
||||
});
|
||||
});
|
||||
|
||||
export const getUserPoints = (username) =>
|
||||
export const getUserPoints = (username) =>
|
||||
new Promise((resolve) => {
|
||||
ePointApi
|
||||
.get(`/users/${username}/points`)
|
||||
@ -50,19 +56,16 @@ export const getUserPoints = (username) =>
|
||||
});
|
||||
});
|
||||
|
||||
export const claim = (username) =>
|
||||
new Promise((resolve, reject) => {
|
||||
ePointApi
|
||||
.put('/claim', {
|
||||
us: `${username}`,
|
||||
})
|
||||
.then((res) => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
export const claimPoints = async () => {
|
||||
try{
|
||||
const response = await ecencyApi.post('/private-api/points-claim')
|
||||
return response.data;
|
||||
}catch(error){
|
||||
console.warn("Failed to calim points", error);
|
||||
bugsnagInstance.notify(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const gameStatusCheck = (username, type) =>
|
||||
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
|
||||
* @param vote vote object(author, permlink, voter, weight)
|
||||
* @param postingKey private posting key
|
||||
*/
|
||||
|
||||
export const vote = (account, pin, author, permlink, weight) =>
|
||||
_vote(account, pin, author, permlink, weight).then((resp) => {
|
||||
userActivity(account.username, 120, resp.block_num, resp.id);
|
||||
export const vote = async (account, pin, author, permlink, weight) => {
|
||||
try {
|
||||
const resp = await _vote(account, pin, author, permlink, weight);
|
||||
userActivity(120, resp.id);
|
||||
console.log('Returning vote response');
|
||||
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 key = getAnyPrivateKey(currentAccount.local, digitPinCode);
|
||||
if (currentAccount.local.authType === AUTH_TYPE.STEEM_CONNECT) {
|
||||
@ -1177,9 +1198,9 @@ export const postContent = (
|
||||
voteWeight,
|
||||
).then((resp) => {
|
||||
const t = title ? 100 : 110;
|
||||
const { block_num, id } = resp;
|
||||
const { id } = resp;
|
||||
if (!isEdit) {
|
||||
userActivity(account.username, t, block_num, id);
|
||||
userActivity(t, id);
|
||||
}
|
||||
return resp;
|
||||
});
|
||||
@ -1303,7 +1324,7 @@ const _postContent = async (
|
||||
// TODO: remove pinCode
|
||||
export const reblog = (account, pinCode, author, permlink) =>
|
||||
_reblog(account, pinCode, author, permlink).then((resp) => {
|
||||
userActivity(account.name, 130, resp.block_num, resp.id);
|
||||
userActivity(130, resp.id);
|
||||
return resp;
|
||||
});
|
||||
|
||||
|
@ -70,7 +70,7 @@ class LoginContainer extends PureComponent {
|
||||
dispatch(setInitPosts([]));
|
||||
dispatch(setFeedPosts([]));
|
||||
|
||||
userActivity(result.name, 20);
|
||||
userActivity(20);
|
||||
setExistUser(true);
|
||||
this._setPushToken(result.name);
|
||||
if (isPinCodeOpen) {
|
||||
|
@ -1171,10 +1171,10 @@
|
||||
dependencies:
|
||||
"@hapi/hoek" "^8.3.0"
|
||||
|
||||
"@hiveio/dhive@^0.14.16":
|
||||
version "0.14.16"
|
||||
resolved "https://registry.yarnpkg.com/@hiveio/dhive/-/dhive-0.14.16.tgz#03602cda2960e511b328fbea7f82aa3e99ce35b7"
|
||||
integrity sha512-HTNwzfJHGLaAEXsLP82OG7U2s57wXwRgfL6QXhgGpLfkBKIEwgsDchB088X4vS0GfmL5RrMyLDXGrWyzwgSCNw==
|
||||
"@hiveio/dhive@^1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@hiveio/dhive/-/dhive-1.0.1.tgz#76bb9e9dbd4cc9efadafd8a40b7025c997a56aba"
|
||||
integrity sha512-j6PEAhLwhSWzMjQiPS0Qsy3jZ+6pAirlnPkgkkb+3q7CGG0eNA7w5VYaFv4OFGecOQfESj7MViYhpzC+5qiq0Q==
|
||||
dependencies:
|
||||
bs58 "^4.0.1"
|
||||
bytebuffer "^5.0.1"
|
||||
|
Loading…
Reference in New Issue
Block a user