@@ -15,25 +15,21 @@ export function useActionPermissions(): ContentActionPermissionCheckers {
1515 const canDelete = ( context : ContentActionContext ) : boolean => {
1616 if ( context . targetType === "post" ) {
1717 // For posts, can only delete if owner and not in embedded mode
18- return context . userRole === "owner" && ! context . isEmbeddedMode ;
18+ return context . isOwner && ! context . isEmbeddedMode ;
1919 } else {
2020 // For comments, can delete if owner (regardless of embed mode)
21- return context . userRole === "owner" ;
21+ return context . isOwner ;
2222 }
2323 } ;
2424
2525 const canModerate = ( context : ContentActionContext ) : boolean => {
2626 // Can moderate if user is a moderator and not in embedded mode
27- return context . userRole === "moderator" && ! context . isEmbeddedMode ;
27+ return context . isModerator && ! context . isEmbeddedMode ;
2828 } ;
2929
3030 const canMute = ( context : ContentActionContext ) : boolean => {
3131 // Can mute if not the owner, user is logged in, and not in embedded mode
32- return (
33- context . userRole !== "owner" &&
34- context . isLoggedIn &&
35- ! context . isEmbeddedMode
36- ) ;
32+ return ! context . isOwner && context . isLoggedIn && ! context . isEmbeddedMode ;
3733 } ;
3834
3935 const canReport = ( ) : boolean => {
@@ -48,7 +44,7 @@ export function useActionPermissions(): ContentActionPermissionCheckers {
4844
4945 const canViewUserReports = ( context : ContentActionContext ) : boolean => {
5046 // Only moderators can view user reports, and not in embedded mode
51- return context . userRole === "moderator" && ! context . isEmbeddedMode ;
47+ return context . isModerator && ! context . isEmbeddedMode ;
5248 } ;
5349
5450 const canViewModerationHistory = ( ) : boolean => {
@@ -73,20 +69,6 @@ export function useActionPermissions(): ContentActionPermissionCheckers {
7369 } ;
7470}
7571
76- /**
77- * Helper function to determine user role based on context
78- */
79- export function determineUserRole (
80- isOwner : boolean ,
81- isModerator : boolean ,
82- isLoggedIn : boolean
83- ) : ContentActionContext [ "userRole" ] {
84- if ( isModerator ) return "moderator" ;
85- if ( isOwner ) return "owner" ;
86- if ( isLoggedIn ) return "user" ;
87- return "anonymous" ;
88- }
89-
9072/**
9173 * Helper function to create action context
9274 */
@@ -100,12 +82,12 @@ export function createActionContext(
10082 isEmbeddedMode : boolean
10183) : ContentActionContext {
10284 const isOwner = currentUser === targetAuthor ;
103- const userRole = determineUserRole ( isOwner , isModerator , isLoggedIn ) ;
10485
10586 return {
106- userRole ,
107- isEmbeddedMode ,
87+ isOwner ,
88+ isModerator ,
10889 isLoggedIn,
90+ isEmbeddedMode,
10991 targetType,
11092 targetId,
11193 targetAuthor,
0 commit comments