Skip to content

Commit 969897f

Browse files
committed
Utilize new predicate to remove directory when permission isn't granted
1 parent 1c70bd2 commit 969897f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/ts/hooks/uiExtender.init.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { MODULE_ID } from "../constants.ts";
22
import { Listener } from "./index.ts";
33
import { ConvenientEffectsV2 } from "../ui/ce-app/convenient-effects-v2.ts";
4+
import { Settings } from "../settings.ts";
45

56
const UiExtenderInit: Listener = {
67
listen(): void {
@@ -13,6 +14,12 @@ const UiExtenderInit: Listener = {
1314
icon: "fas fa-hand-sparkles",
1415
order: 5,
1516
applicationClass: ConvenientEffectsV2,
17+
predicate: () => {
18+
const settings = new Settings();
19+
const hasAppPermission =
20+
game.user.role >= settings.appControlsPermission;
21+
return hasAppPermission;
22+
},
1623
});
1724
});
1825
},

types/uiExtender/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ declare global {
232232
* The application of the directory
233233
*/
234234
applicationClass: new (...args: any[]) => AbstractSidebarTab;
235+
236+
/**
237+
* The predicate to determine if the directory should be added
238+
*
239+
* @returns true if the directory should be added, false otherwise
240+
*/
241+
predicate?: () => boolean;
235242
}
236243

237244
namespace Hooks {

0 commit comments

Comments
 (0)