Block a cid (hide a comment)
Block a cid (hide a comment) in Bitsocial React Hooks. Usage, options, and examples.
const { blocked, unblock, block } = useBlock({ cid: "Qm..." });
if (blocked) {
console.log(`'${cid}' is blocked`);
} else {
console.log(`'${cid}' is not blocked`);
}
// to block
block();
// to unblock
unblock();
Feeds leave out the posts whose cid the account blocked. Use includeBlockedCids to keep them in a feed, for example to count the hidden posts or to offer an “unhide all” view:
const account = useAccount();
const { feed } = useFeed({
communities: [{ name: communityAddress }],
includeBlockedCids: true,
});
const hiddenPosts = feed.filter((post) => account.blockedCids[post.cid]);
includeBlockedCids only opts out of the blocked cids: posts from blocked communities and blocked authors (useBlock({address})) and posts rejected by filter are still left out. It is a useFeed option; useReplies and useBufferedFeeds do not have it (replies are not filtered by blocked cids).