Skip to content

Commit

Permalink
Merge branch 'filtering-app-posts' into remove-sbd-refs
Browse files Browse the repository at this point in the history
  • Loading branch information
netuoso committed Sep 24, 2018
2 parents 29dabb3 + 86d8b7c commit 5c30d4c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/app/components/cards/PostsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import LoadingIndicator from 'app/components/elements/LoadingIndicator';
import debounce from 'lodash.debounce';
import CloseButton from 'app/components/elements/CloseButton';
import { findParent } from 'app/utils/DomUtils';
import { shouldDisplayPost } from 'app/utils/StateFunctions';
import Icon from 'app/components/elements/Icon';
import shouldComponentUpdate from 'app/utils/shouldComponentUpdate';

Expand Down Expand Up @@ -165,7 +166,8 @@ class PostsList extends React.Component {
const ignore =
ignore_result && ignore_result.has(cont.get('author'));
const hide = cont.getIn(['stats', 'hide']);
if (!(ignore || hide) || showSpam)
var show = shouldDisplayPost(this.props, item);
if (show && (!(ignore || hide) || showSpam))
// rephide
postsInfo.push({ item, ignore });
});
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/elements/ReplyEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ export default formId =>
if (rtags.links.size) meta.links = rtags.links;
else delete meta.links;

meta.app = 'steemit/0.1';
meta.app = 'touchit-social/0.1';
if (isStory) {
meta.format = isHtml ? 'html' : 'markdown';
}
Expand Down Expand Up @@ -929,6 +929,8 @@ export default formId =>
return;
}

meta.tags.push('touchit-social');

startLoadingIndicator();

const originalBody = isEdit ? originalPost.body : null;
Expand Down
18 changes: 17 additions & 1 deletion src/app/components/pages/PostsIndex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { actions as fetchDataSagaActions } from 'app/redux/FetchDataSaga';
import constants from 'app/redux/constants';
import shouldComponentUpdate from 'app/utils/shouldComponentUpdate';
import PostsList from 'app/components/cards/PostsList';
import { isFetchingOrRecentlyUpdated } from 'app/utils/StateFunctions';
import {
isFetchingOrRecentlyUpdated,
shouldDisplayPost,
} from 'app/utils/StateFunctions';
import Callout from 'app/components/elements/Callout';
// import SidebarStats from 'app/components/elements/SidebarStats';
import SidebarLinks from 'app/components/elements/SidebarLinks';
Expand All @@ -22,6 +25,7 @@ class PostsIndex extends React.Component {
static propTypes = {
discussions: PropTypes.object,
accounts: PropTypes.object,
content: PropTypes.object,
status: PropTypes.object,
routeParams: PropTypes.object,
requestData: PropTypes.func,
Expand Down Expand Up @@ -133,6 +137,13 @@ class PostsIndex extends React.Component {
}
} else {
posts = this.getPosts(order, category);

if (posts) {
posts = posts.filter(post => {
return shouldDisplayPost(this.props, post);
});
}

if (posts && posts.size === 0) {
emptyText = (
<div>
Expand Down Expand Up @@ -192,6 +203,7 @@ class PostsIndex extends React.Component {
const layoutClass = this.props.blogmode
? ' layout-block'
: ' layout-list';

return (
<div
className={
Expand Down Expand Up @@ -289,6 +301,7 @@ module.exports = {
status: state.global.get('status'),
loading: state.app.get('loading'),
accounts: state.global.get('accounts'),
content: state.global.get('content'),
username:
state.user.getIn(['current', 'username']) ||
state.offchain.get('account'),
Expand All @@ -297,6 +310,9 @@ module.exports = {
topic: ownProps.params.category,
categories: state.global
.getIn(['tag_idx', 'trending'])
.filter(e => {
return ['touch-tube', 'touchit-social'].indexOf(e) < 0;
})
.take(50),
maybeLoggedIn: state.user.get('maybeLoggedIn'),
isBrowser: process.env.BROWSER,
Expand Down
11 changes: 11 additions & 0 deletions src/app/utils/StateFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,14 @@ export function filterTags(tags) {
.filter(tag => typeof tag === 'string')
.filter((value, index, self) => value && self.indexOf(value) === index);
}

export function shouldDisplayPost(state, post) {
try {
let json_metadata = JSON.parse(
state.content.get(post).get('json_metadata')
);
return json_metadata.tags.includes('touchit-social');
} catch (e) {
return false;
}
}

0 comments on commit 5c30d4c

Please sign in to comment.