skipping body removal for comments list

This commit is contained in:
Nouman Tahir 2021-03-23 11:41:03 +05:00
parent b102e149a7
commit 7222075bf7
2 changed files with 10 additions and 10 deletions

View File

@ -462,9 +462,8 @@ export const getRankedPosts = async (query, currentUserName, filterNsfw) => {
let posts = await client.call('bridge', 'get_ranked_posts', query); let posts = await client.call('bridge', 'get_ranked_posts', query);
if (posts) { if (posts) {
posts = parsePosts(posts, currentUserName); const areComments = query.sort === 'comments';
posts = parsePosts(posts, currentUserName, areComments);
// FastImage.preload(posts.map(post=>({uri:post.image})))
if (filterNsfw !== '0') { if (filterNsfw !== '0') {
const updatedPosts = filterNsfwPost(posts, filterNsfw); const updatedPosts = filterNsfwPost(posts, filterNsfw);
@ -484,9 +483,8 @@ export const getAccountPosts = async (query, currentUserName, filterNsfw) => {
let posts = await client.call('bridge', 'get_account_posts', query); let posts = await client.call('bridge', 'get_account_posts', query);
if (posts) { if (posts) {
posts = parsePosts(posts, currentUserName); const areComments = query.sort === 'comments';
posts = parsePosts(posts, currentUserName, areComments);
// FastImage.preload(posts.map(post=>({uri:post.image})))
if (filterNsfw !== '0') { if (filterNsfw !== '0') {
const updatedPosts = filterNsfwPost(posts, filterNsfw); const updatedPosts = filterNsfwPost(posts, filterNsfw);

View File

@ -12,15 +12,17 @@ import { getResizedAvatar, getResizedImage } from './image';
const webp = Platform.OS === 'ios' ? false : true; const webp = Platform.OS === 'ios' ? false : true;
export const parsePosts = (posts, currentUserName) => { export const parsePosts = (posts, currentUserName, areComments) => {
if (posts) { if (posts) {
const formattedPosts = posts.map((post) => parsePost(post, currentUserName, false, true)); const formattedPosts = posts.map((post) =>
parsePost(post, currentUserName, false, true, areComments),
);
return formattedPosts; return formattedPosts;
} }
return null; return null;
}; };
export const parsePost = (post, currentUserName, isPromoted, isList = false) => { export const parsePost = (post, currentUserName, isPromoted, isList = false, isComment = false) => {
if (!post) { if (!post) {
return null; return null;
} }
@ -63,7 +65,7 @@ export const parsePost = (post, currentUserName, isPromoted, isList = false) =>
post.post_fetched_at = new Date().getTime(); post.post_fetched_at = new Date().getTime();
//discard post body if list //discard post body if list
if (isList) { if (isList && !isComment) {
post.body = ''; post.body = '';
} }