refactor(core): remove legacy plebbit terminology

This commit is contained in:
Tommaso Casaburi
2026-04-17 10:48:27 +07:00
parent e366dac25c
commit ee7a5b5778
158 changed files with 626 additions and 836 deletions
+5 -4
View File
@@ -1,5 +1,6 @@
import type { Comment } from '@bitsocialnet/bitsocial-react-hooks';
import communitiesStore from '@bitsocialnet/bitsocial-react-hooks/dist/stores/communities';
import { getCommentCommunityAddress } from './comment-utils';
type CommunityLike = {
roles?: Record<string, { role?: string }>;
@@ -142,20 +143,20 @@ export const displayNameMatchesPattern = (comment: Comment, pattern: string): bo
* @returns True if the user has the specified role, false otherwise
*/
export const userHasRole = (comment: Comment, role: string): boolean => {
const communityAddress = (comment as { communityAddress?: string }).communityAddress ?? comment?.subplebbitAddress;
const communityAddress = getCommentCommunityAddress(comment);
if (!role || !comment?.author?.address || !communityAddress) {
return false;
}
const communities = communitiesStore.getState().communities;
const subplebbit = communities[communityAddress] as CommunityLike | undefined;
const community = communities[communityAddress] as CommunityLike | undefined;
if (!subplebbit?.roles) {
if (!community?.roles) {
return false;
}
const userRole = subplebbit.roles[comment.author.address]?.role;
const userRole = community.roles[comment.author.address]?.role;
// Handle different role names (moderator/mod)
if ((role.toLowerCase() === 'moderator' || role.toLowerCase() === 'mod') && userRole === 'moderator') {