Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
Fixed bug steemit#3929 (View / Collapse Doesn't Work with 2 Pinned Posts)
  • Loading branch information
the-gorilla-steem committed Nov 28, 2024
1 parent 4a88802 commit e879072
Showing 1 changed file with 68 additions and 4 deletions.
72 changes: 68 additions & 4 deletions src/app/components/cards/PostsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ class PostsList extends React.Component {
blist: [],
currentSlide: 0,
arePinnedPostsCollapsed: false,
hideResteems: process.env.BROWSER
? localStorage.getItem('hideResteems') === 'true'
: false,
};
this.scrollListener = this.scrollListener.bind(this);
this.onBackButton = this.onBackButton.bind(this);
this.shouldComponentUpdate = shouldComponentUpdate(this, 'PostsList');
this.nextSlide = this.nextSlide.bind(this);
this.prevSlide = this.prevSlide.bind(this);
this.togglePinnedPosts = this.togglePinnedPosts.bind(this);
this.handleToggleHideResteems = this.handleToggleHideResteems.bind(
this
);
}

componentDidMount() {
Expand Down Expand Up @@ -192,6 +198,17 @@ class PostsList extends React.Component {
);
}

handleToggleHideResteems() {
this.setState(prevState => {
const newHideResteems = !prevState.hideResteems;
if (process.env.BROWSER) {
localStorage.setItem('hideResteems', newHideResteems);
console.log('Storing HideResteems: ', newHideResteems);
}
return { hideResteems: newHideResteems };
});
}

render() {
const {
posts,
Expand All @@ -201,8 +218,19 @@ class PostsList extends React.Component {
nsfwPref,
hideCategory,
depth,
following,
} = this.props;
const { thumbSize, currentSlide, arePinnedPostsCollapsed } = this.state;
const {
thumbSize,
currentSlide,
arePinnedPostsCollapsed,
hideResteems,
} = this.state;

//console.log('Category: ', category);
//console.log('Order: ', order);
//console.log('Following: ', following);
//console.log('Hide Resteems', hideResteems);

const pinnedPosts = posts.filter(post =>
post.getIn(['stats', 'is_pinned'], false)
Expand All @@ -222,14 +250,21 @@ class PostsList extends React.Component {
/>
);

//console.log('Author: ', post.get('author'), following.includes(post.get('author')), post.get('reblogged_by'), post.getIn(['stats', 'is_pinned'], false));

const summary = [];
summary.push(
<li
key={i}
className={
post.getIn(['stats', 'is_pinned'], false)
(post.getIn(['stats', 'is_pinned'], false)
? 'isPinned'
: ''
: '') +
(hideResteems &&
post.get('reblogged_by') &&
!following.includes(post.get('author'))
? ' hideResteems'
: '')
}
>
{ps}
Expand Down Expand Up @@ -276,13 +311,24 @@ class PostsList extends React.Component {

return (
<div id="posts_list" className="PostsList">
{order === 'feed' && (
<div>
<input
type="checkbox"
checked={hideResteems}
onChange={this.handleToggleHideResteems}
id="hideResteems"
/>
<label htmlFor="hideResteems">Hide Resteems</label>
</div>
)}
{category &&
category.startsWith('hive-') &&
pinnedPostsCount > 0 &&
(order === 'trending' || order === 'created') && (
<div
className={`${
arePinnedPostsCollapsed && pinnedPostsCount > 2
arePinnedPostsCollapsed && pinnedPostsCount >= 2
? 'pinnedPostsContainer'
: ''
}`}
Expand Down Expand Up @@ -387,6 +433,23 @@ export default connect(
['follow', 'getFollowingAsync', username, 'ignore_result'],
List()
);
let following = props.category;
if (
props.category &&
props.category.startsWith('@') &&
props.order === 'feed'
) {
following = state.global.getIn(
[
'follow',
'getFollowingAsync',
props.category.slice(1),
'blog_result',
],
List()
);
}

const blacklist = state.global.get('blacklist');
let { posts } = props;
if (typeof posts === 'undefined') {
Expand Down Expand Up @@ -417,6 +480,7 @@ export default connect(
videoAdsEnabled,
adSlots,
blacklist,
following,
};
},
dispatch => ({
Expand Down

0 comments on commit e879072

Please sign in to comment.