1 import { CommunityModeratorView, PersonView } from "lemmy-js-client";
2 import { UserService } from "../../services";
4 export default function canMod(
6 mods?: CommunityModeratorView[],
8 myUserInfo = UserService.Instance.myUserInfo,
11 // You can do moderator actions only on the mods added after you.
14 ?.map(a => a.person.id)
15 .concat(mods?.map(m => m.moderator.id) ?? []) ?? [];
18 const myIndex = adminsThenMods.findIndex(
19 id => id === myUserInfo.local_user_view.person.id,
24 // onSelf +1 on mod actions not for yourself, IE ban, remove, etc
25 adminsThenMods = adminsThenMods.slice(0, myIndex + (onSelf ? 0 : 1));
26 return !adminsThenMods.includes(creator_id);