Get your own comments and votes
Get your own comments and votes in Bitsocial React Hooks. Usage, options, and examples.
// all my own comments
const { accountComments } = useAccountComments();
for (const accountComment of accountComments) {
// it is recommended to show a label in the UI if accountComment.state is 'pending' or 'failed'
console.log("comment", accountComment.index, "is status", accountComment.state);
}
// `state` becomes `failed` as soon as a pending local publish records terminal failure (`publishingState === "failed"` and `state === "stopped"`) or a publish error, instead of waiting for the 20-minute fallback.
// local account comments returned by useAccountComment and useAccountComments include the account author's address and shortAddress when an older cached account comment is missing author identity fields.
// comments published in a pseudonymous community (comment.pseudonymityMode is set) keep their community-assigned author instead, because the account identity was never published.
// note: accountComment.index can change after deletions; prefer commentCid for stable identifiers
// all my own votes
const { accountVotes } = useAccountVotes();
// my own comments in memes.eth
const communityAddress = "memes.eth";
const myCommentsInMemesEth = useAccountComments({ communityAddress });
// my own posts in memes.eth
const filter = useCallback(
(comment) => comment.communityAddress === communityAddress && !comment.parentCid,
[communityAddress],
);
const myPostsInMemesEth = useAccountComments({ filter });
// my own replies in a post with cid 'Qm...'
const postCid = "Qm...";
const filter = useCallback((comment) => comment.postCid === postCid, [postCid]);
const myCommentsInSomePost = useAccountComments({ filter });
// my own replies to a comment with cid 'Qm...'
const parentCommentCid = "Qm...";
const myRepliesToSomeComment = useAccountComments({ parentCid: parentCommentCid });
// recent own comments in memes.eth, newest first, one page at a time
const recentMyCommentsInMemesEth = useAccountComments({
communityAddress,
newerThan: 60 * 60 * 24 * 30,
sortType: "new",
page: 0,
pageSize: 20,
});
// get one own comment directly by cid
const accountComment = useAccountComment({ commentCid: "Qm..." });
// get a specific set of own comments by account comment index
const replacementReplies = useAccountComments({ commentIndices: [5, 7, 9] });
// voted profile tab helpers
const recentUpvotes = useAccountVotes({
vote: 1,
newerThan: 60 * 60 * 24 * 30,
sortType: "new",
page: 0,
pageSize: 20,
});
// know if you upvoted a comment already with cid 'Qm...'
const { vote } = useAccountVote({ commentCid: "Qm..." });
console.log(vote); // 1, -1 or 0
// my own pending posts in a feed
const { feed } = useFeed({
communities: [{ name: communityAddress }],
accountComments: { newerThan: Infinity, append: false },
});
// my own pending replies in a replies feed
const { replies } = useReplies({
comment: post,
accountComments: { newerThan: Infinity, append: false },
});
// pending local account comments are reconciled with their approved network version
// so the same post or reply is not shown twice after moderation approval
// published account replies stay visible and are deduplicated by cid while
// canonical replies propagate; explicitly purged replies are hidden after an
// exhausted canonical feed refreshes past their timestamp