This is a feature that was recently merged and deployed into Steemit. Earlier I submitted a pull request to add the feature to filter resteemed posts from a given user's profile page. This was a long-requested feature that has various workarounds through browser extensions and handled in various alternative interfaces, but I just wanted to make it work in Steemit.
Here is how it looks when you look at the user's profile. There's a little link now that shows up when you first load the page that indicates "Hide Resteems":
Once clicked, it will remove the resteemed posts from the page immediately, and show up as "Show All", like so:
Since all the post data is preserved, this switch is relatively insant. Now when you scroll to the bottom, if you are in the hide-resteem mode, it will fetch more posts until either a certain number of main posts are found, or an upper limit of post fetches is reached. So for example, if you go to see a resteem-only page, it will just be blank.
If every single post in the feed is a resteem, or if there's only 1 main post, it's possible that it doesn't retrigger a re-fetch until you resize, which is a slight annoyance. In the majority of the cases though, I don't expect too many problems.
While this kind of filtering is normally something done by the database, there was no database-like backing to do such a thing, and it would likely need HiveMind support to do it in that way. So I investigated just to do something that we as end-users would end up doing anyway: repeated fetching until we finally found posts that are not resteems (if looking at a resteem-heavy profile).
If you follow my list of files: https://github.com/steemit/condenser/pull/2897/files the change boils down to a few components:
- Link and Text, linked to the action of requesting to hide resteems, which is here. Oh dear, I forgot to localize that text!
- Propagating the Signal to the code that performs the data fetch. This isn't anything special, you'll see in the first few files of the link that a
showResteemboolean is being passed around. Something of note here is that a predicate is formed here and passed down to the data fetch code.
- Modifying the Data fetch to perform repeat fetches until the required number of filtered posts are found, or until the max batch size limit is reached.
- I changed the fetch into a loop here. One thing to note in this loop is that it does not discard anything. It retains all fetched posts and passes it up, and relies on the front end to actually filter it. So essentially, this simply fetches until the number of posts that match the filter fills up the batch.
- There's a piece of code here that has a signal where if it knows there is no more data to fetch, it will signal to the top that it should wait a short period of time before requesting another fetch for the same data. It was modified to rely on the caller to pass the signal for end of data.
- Oops. I left some unused code around, will need to clean that up! Will need to clean this up shortly
- Code to hide the resteemed posts. That is here, which is pretty straight forward, it detects the signal for whether to hide the resteems, and checks if it is a resteem or not to decide whether not to show the item.
- Tests, for the rest of the files. Nothing too exciting here, sets up the fetch with the filter and runs multiple cases, including the case where it fetches until a max batch size is reached.
If you are curious about any part of the change, do let me know and ask below.