fix(post): show specific role in moderation posting warning

Replace the generic "posting as moderator" label with the effective role
(5chan dev, owner, admin, or moderator) in post and reply forms.
This commit is contained in:
Tommaso Casaburi
2026-06-01 12:48:42 +07:00
parent d48cf10ee8
commit 812b6bc79c
6 changed files with 47 additions and 6 deletions
+4 -1
View File
@@ -18,6 +18,7 @@ import {
} from '../../lib/utils/post-options-utils';
import { getPublishURLFilename, isValidPublishURL } from '../../lib/utils/url-utils';
import { hasModQueueAccessRole } from '../../lib/utils/mod-access';
import { getModerationPostingRoleLabel } from '../../lib/utils/author-display-utils';
import { isAllView, isModView, isSubscriptionsView } from '../../lib/utils/view-utils';
import useSelectedTextStore from '../../stores/use-selected-text-store';
import useReplyModalStore from '../../stores/use-reply-modal-store';
@@ -81,6 +82,8 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, parentNumber, threa
const roles = useCommunityField(communityAddress, (community) => community?.roles);
const accountRole = accountAddress ? roles?.[accountAddress]?.role : undefined;
const showBbcodeToolbar = hasModQueueAccessRole(accountRole);
const moderationPostingRoleLabel = getModerationPostingRoleLabel({ address: accountAddress, role: accountRole });
const moderationPostingWarning = showBbcodeToolbar && moderationPostingRoleLabel ? `warning: posting as ${moderationPostingRoleLabel}` : undefined;
const textRef = useRef<HTMLTextAreaElement | null>(null);
const setTextRef = useRef((element: HTMLTextAreaElement | null) => {
textRef.current = element;
@@ -609,7 +612,7 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, parentNumber, threa
{t('post')}
</button>
</div>
{showBbcodeToolbar ? <div className={styles.error}>warning: posting as moderator</div> : null}
{moderationPostingWarning ? <div className={styles.error}>{moderationPostingWarning}</div> : null}
{lengthError ? (
<div className={styles.error}>{lengthError}</div>
) : error ? (