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