mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-15 00:23:34 +03:00
commit
f967679b5c
@ -36,7 +36,7 @@ const PostCardView = ({
|
||||
}) => {
|
||||
const [rebloggedBy, setRebloggedBy] = useState(get(content, 'reblogged_by[0]', null));
|
||||
const [activeVot, setActiveVot] = useState(activeVotes);
|
||||
|
||||
//console.log(activeVotes);
|
||||
// Component Functions
|
||||
|
||||
const _handleOnUserPress = () => {
|
||||
|
@ -147,10 +147,16 @@ const PostsContainer = ({
|
||||
|
||||
const filter = type || selectedFilterValue;
|
||||
let options = {};
|
||||
const limit = 4;
|
||||
const limit = 7;
|
||||
let func = null;
|
||||
|
||||
if (filter === 'feed' || filter === 'blog' || getFor === 'blog' || filter === 'reblogs') {
|
||||
if (
|
||||
filter === 'feed' ||
|
||||
filter === 'posts' ||
|
||||
filter === 'blog' ||
|
||||
getFor === 'blog' ||
|
||||
filter === 'reblogs'
|
||||
) {
|
||||
func = getAccountPosts;
|
||||
options = {
|
||||
account: feedUsername,
|
||||
@ -158,7 +164,7 @@ const PostsContainer = ({
|
||||
sort: filter,
|
||||
};
|
||||
|
||||
if (pageType === 'profiles' && filter === 'feed') {
|
||||
if (pageType === 'profiles' && (filter === 'feed' || filter === 'posts')) {
|
||||
options.sort = 'posts';
|
||||
}
|
||||
} else {
|
||||
@ -194,14 +200,14 @@ const PostsContainer = ({
|
||||
_posts = unionBy(posts, _posts, 'permlink');
|
||||
}
|
||||
}
|
||||
if (posts.length <= 4 && pageType !== 'profiles') {
|
||||
if (posts.length <= 7 && pageType !== 'profiles') {
|
||||
_setFeedPosts(_posts);
|
||||
}
|
||||
|
||||
if (!refreshing) {
|
||||
setStartAuthor(result[result.length - 1] && result[result.length - 1].author);
|
||||
setStartPermlink(result[result.length - 1] && result[result.length - 1].permlink);
|
||||
}
|
||||
//if (!refreshing) {
|
||||
setStartAuthor(result[result.length - 1] && result[result.length - 1].author);
|
||||
setStartPermlink(result[result.length - 1] && result[result.length - 1].permlink);
|
||||
//}
|
||||
setPosts(_posts);
|
||||
}
|
||||
} else if (result.length === 0) {
|
||||
|
@ -1,11 +1,12 @@
|
||||
import axios from 'axios';
|
||||
import Config from 'react-native-config';
|
||||
import VersionNumber from 'react-native-version-number';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: Config.BACKEND_URL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': Config.USER_AGENT,
|
||||
'User-Agent': `${Config.USER_AGENT}/${VersionNumber.appVersion}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -238,7 +238,8 @@
|
||||
"top": "Top",
|
||||
"hot": "Hot",
|
||||
"new": "New",
|
||||
"blog": "Blog"
|
||||
"blog": "Blog",
|
||||
"posts": "Posts"
|
||||
},
|
||||
"side_menu": {
|
||||
"profile": "Profile",
|
||||
|
@ -4,8 +4,8 @@ export const POPULAR_FILTERS_VALUE = ['feed', 'trending', 'hot', 'created'];
|
||||
export const GLOBAL_POST_FILTERS = ['TOP', 'HOT', 'NEW'];
|
||||
export const GLOBAL_POST_FILTERS_VALUE = ['trending', 'hot', 'created'];
|
||||
|
||||
export const PROFILE_FILTERS = ['BLOG', 'FEED'];
|
||||
export const PROFILE_FILTERS_VALUE = ['blog', 'feed'];
|
||||
export const PROFILE_FILTERS = ['BLOG', 'POSTS'];
|
||||
export const PROFILE_FILTERS_VALUE = ['blog', 'posts'];
|
||||
|
||||
// 'TRENDING',
|
||||
// 'HOT',
|
||||
|
@ -14,10 +14,10 @@ import {
|
||||
ignoreUser,
|
||||
getFollows,
|
||||
getRepliesByLastUpdate,
|
||||
getUserComments,
|
||||
getUser,
|
||||
getIsFollowing,
|
||||
getIsMuted,
|
||||
getAccountPosts,
|
||||
} from '../providers/steem/dsteem';
|
||||
|
||||
// Ecency providers
|
||||
@ -91,17 +91,39 @@ class ProfileContainer extends Component {
|
||||
currentAccount: { name: currentAccountUsername },
|
||||
isAnalytics,
|
||||
} = this.props;
|
||||
this.setState({ isProfileLoading: true });
|
||||
let repliesAction;
|
||||
|
||||
if (!isOwnProfile) {
|
||||
repliesAction = getUserComments;
|
||||
repliesAction = getAccountPosts;
|
||||
if (query) {
|
||||
query.account = query.author;
|
||||
if (comments.length > 0) {
|
||||
query.start_author = query.author;
|
||||
query.start_permlink = query.permlink;
|
||||
}
|
||||
query.limit = 5;
|
||||
query.observer = '';
|
||||
query.sort = 'comments';
|
||||
}
|
||||
|
||||
if (isAnalytics && user) {
|
||||
Matomo.trackView([`/@${user.name}/comments`]).catch((error) =>
|
||||
console.warn('Failed to track screen', error),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
repliesAction = getRepliesByLastUpdate;
|
||||
repliesAction = getAccountPosts;
|
||||
if (query) {
|
||||
query.account = query.author;
|
||||
if (comments.length > 0) {
|
||||
query.start_author = query.author;
|
||||
query.start_permlink = query.permlink;
|
||||
}
|
||||
query.limit = 5;
|
||||
query.observer = '';
|
||||
query.sort = 'replies';
|
||||
}
|
||||
|
||||
if (isAnalytics) {
|
||||
Matomo.trackView([`/@${currentAccountUsername}/replies`]).catch((error) =>
|
||||
console.warn('Failed to track screen', error),
|
||||
@ -109,14 +131,14 @@ class ProfileContainer extends Component {
|
||||
}
|
||||
}
|
||||
if (query) {
|
||||
await repliesAction({
|
||||
start_author: query.author,
|
||||
start_permlink: query.permlink,
|
||||
limit: 10,
|
||||
}).then((result) => {
|
||||
delete query.author;
|
||||
delete query.permlink;
|
||||
console.log(query);
|
||||
repliesAction(query).then((result) => {
|
||||
let _comments = unionBy(comments, result, 'permlink');
|
||||
this.setState({
|
||||
comments: _comments,
|
||||
isProfileLoading: false,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -442,18 +442,6 @@ export const getAccountPosts = async (query, currentUserName, filterNsfw) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getUserComments = async (query) => {
|
||||
try {
|
||||
query.sort = 'comments';
|
||||
query.account = query.start_author;
|
||||
const _comments = await client.call('bridge', 'get_account_posts', query);
|
||||
const groomedComments = parseComments(_comments);
|
||||
return groomedComments;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
};
|
||||
|
||||
export const getRepliesByLastUpdate = async (query) => {
|
||||
try {
|
||||
const replies = await client.database.call('get_replies_by_last_update', [
|
||||
@ -536,8 +524,8 @@ export const deleteComment = (currentAccount, pin, permlink) => {
|
||||
|
||||
export const getComments = async (author, permlink, currentUserName = null) => {
|
||||
try {
|
||||
//const comments = await client.call('bridge', 'get_discussion', [author, permlink]);
|
||||
const comments = await client.database.call('get_content_replies', [author, permlink]);
|
||||
|
||||
const groomedComments = parseComments(comments, currentUserName);
|
||||
|
||||
return comments ? groomedComments : null;
|
||||
@ -1121,9 +1109,9 @@ export const postContent = (
|
||||
title,
|
||||
body,
|
||||
jsonMetadata,
|
||||
isEdit = false,
|
||||
options = null,
|
||||
voteWeight = null,
|
||||
isEdit = false,
|
||||
) =>
|
||||
_postContent(
|
||||
account,
|
||||
|
@ -1,12 +1,6 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const DEFAULT_SERVER = [
|
||||
'https://rpc.esteem.app',
|
||||
'https://anyx.io',
|
||||
'https://api.pharesim.me',
|
||||
'https://api.hive.blog',
|
||||
'https://api.hivekings.com',
|
||||
];
|
||||
const DEFAULT_SERVER = ['https://rpc.ecency.com', 'https://anyx.io', 'https://api.hive.blog'];
|
||||
|
||||
const pickAServer = () => DEFAULT_SERVER.sort(() => 0.5 - Math.random())[0];
|
||||
|
||||
|
@ -14,19 +14,27 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode, isL
|
||||
const tag = get(navigation, 'state.params.tag');
|
||||
|
||||
useEffect(() => {
|
||||
getCommunity(tag).then((res) => {
|
||||
setData(res);
|
||||
});
|
||||
getCommunity(tag)
|
||||
.then((res) => {
|
||||
setData(res);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
}, [tag]);
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
getSubscriptions(currentAccount.username).then((result) => {
|
||||
if (result) {
|
||||
const _isSubscribed = result.some((item) => item[0] === data.name);
|
||||
setIsSubscribed(_isSubscribed);
|
||||
}
|
||||
});
|
||||
getSubscriptions(currentAccount.username)
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
const _isSubscribed = result.some((item) => item[0] === data.name);
|
||||
setIsSubscribed(_isSubscribed);
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
@ -36,9 +44,13 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode, isL
|
||||
communityId: data.name,
|
||||
};
|
||||
|
||||
subscribeCommunity(currentAccount, pinCode, _data).then((result) => {
|
||||
setIsSubscribed(!isSubscribed);
|
||||
});
|
||||
subscribeCommunity(currentAccount, pinCode, _data)
|
||||
.then((result) => {
|
||||
setIsSubscribed(!isSubscribed);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
};
|
||||
|
||||
const _handleNewPostButtonPress = () => {
|
||||
|
@ -328,6 +328,7 @@ class EditorContainer extends Component {
|
||||
beneficiaries: beneficiaries,
|
||||
});
|
||||
const parentPermlink = _tags[0] || 'hive-125125';
|
||||
const voteWeight = null;
|
||||
|
||||
if (scheduleDate) {
|
||||
await this._setScheduledPost({
|
||||
@ -347,7 +348,7 @@ class EditorContainer extends Component {
|
||||
fields.body,
|
||||
jsonMeta,
|
||||
options,
|
||||
0,
|
||||
voteWeight,
|
||||
)
|
||||
.then(() => {
|
||||
setDraftPost(
|
||||
@ -400,14 +401,16 @@ class EditorContainer extends Component {
|
||||
const jsonMeta = makeJsonMetadataReply(post.json_metadata.tags || ['ecency']);
|
||||
const permlink = generateReplyPermlink(post.author);
|
||||
const author = currentAccount.name;
|
||||
const options = makeOptions({
|
||||
const options = null;
|
||||
/*makeOptions({
|
||||
author: author,
|
||||
permlink: permlink,
|
||||
operationType: rewardType,
|
||||
beneficiaries: beneficiaries,
|
||||
});
|
||||
});*/
|
||||
const parentAuthor = post.author;
|
||||
const parentPermlink = post.permlink;
|
||||
const voteWeight = null;
|
||||
|
||||
await postContent(
|
||||
currentAccount,
|
||||
@ -419,7 +422,7 @@ class EditorContainer extends Component {
|
||||
fields.body,
|
||||
jsonMeta,
|
||||
options,
|
||||
0,
|
||||
voteWeight,
|
||||
)
|
||||
.then(() => {
|
||||
AsyncStorage.setItem('temp-reply', '');
|
||||
@ -464,16 +467,17 @@ class EditorContainer extends Component {
|
||||
} catch (e) {
|
||||
jsonMeta = makeJsonMetadata(meta, tags);
|
||||
}
|
||||
|
||||
await postContent(
|
||||
currentAccount,
|
||||
pinCode,
|
||||
parentAuthor,
|
||||
parentPermlink,
|
||||
parentAuthor || '',
|
||||
parentPermlink || '',
|
||||
permlink,
|
||||
title,
|
||||
newBody,
|
||||
jsonMeta,
|
||||
null,
|
||||
null,
|
||||
isEdit,
|
||||
)
|
||||
.then(() => {
|
||||
|
@ -69,33 +69,33 @@ export const makeOptions = (postObj) => {
|
||||
permlink: postObj.permlink,
|
||||
max_accepted_payout: '1000000.000 HBD',
|
||||
percent_hbd: 10000,
|
||||
extensions: [[0, { beneficiaries: [] }]],
|
||||
extensions: [],
|
||||
};
|
||||
switch (postObj.operationType) {
|
||||
case 'sp':
|
||||
a.max_accepted_payout = '1000000.000 HBD';
|
||||
a.percent_hbd = 0;
|
||||
if (postObj.beneficiaries.length > 0) {
|
||||
if (postObj.beneficiaries && postObj.beneficiaries.length > 0) {
|
||||
postObj.beneficiaries.sort((a, b) => a.account.localeCompare(b.account));
|
||||
a.extensions[0][1].beneficiaries = postObj.beneficiaries || [];
|
||||
a.extensions = [[0, { beneficiaries: postObj.beneficiaries }]];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'dp':
|
||||
a.max_accepted_payout = '0.000 HBD';
|
||||
a.percent_hbd = 10000;
|
||||
if (postObj.beneficiaries.length > 0) {
|
||||
if (postObj.beneficiaries && postObj.beneficiaries.length > 0) {
|
||||
postObj.beneficiaries.sort((a, b) => a.account.localeCompare(b.account));
|
||||
a.extensions[0][1].beneficiaries = postObj.beneficiaries || [];
|
||||
a.extensions = [[0, { beneficiaries: postObj.beneficiaries }]];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
a.max_accepted_payout = '1000000.000 HBD';
|
||||
a.percent_hbd = 10000;
|
||||
if (postObj.beneficiaries.length > 0) {
|
||||
if (postObj.beneficiaries && postObj.beneficiaries.length > 0) {
|
||||
postObj.beneficiaries.sort((a, b) => a.account.localeCompare(b.account));
|
||||
a.extensions[0][1].beneficiaries = postObj.beneficiaries || [];
|
||||
a.extensions = [[0, { beneficiaries: postObj.beneficiaries }]];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ export const isVoted = (activeVotes, currentUserName) => {
|
||||
(element) => get(element, 'voter') === currentUserName && get(element, 'rshares', 0) > 0,
|
||||
);
|
||||
if (result) {
|
||||
return result.percent;
|
||||
return result.rshares;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@ -120,7 +120,7 @@ export const isDownVoted = (activeVotes, currentUserName) => {
|
||||
(element) => get(element, 'voter') === currentUserName && get(element, 'rshares') < 0,
|
||||
);
|
||||
if (result) {
|
||||
return result.percent;
|
||||
return result.rshares;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user