2025-01-11 01:46:00 +02:00
|
|
|
import type FNote from "../../../entities/fnote.js";
|
2022-12-02 16:46:14 +01:00
|
|
|
import AbstractLauncher from "./abstract_launcher.js";
|
|
|
|
|
|
|
|
export default class ScriptLauncher extends AbstractLauncher {
|
2025-01-11 01:46:00 +02:00
|
|
|
constructor(launcherNote: FNote) {
|
2022-12-02 16:46:14 +01:00
|
|
|
super(launcherNote);
|
|
|
|
|
2022-12-18 22:05:06 +01:00
|
|
|
this.title(() => this.launcherNote.title)
|
|
|
|
.icon(() => this.launcherNote.getIcon())
|
2022-12-17 21:46:51 +01:00
|
|
|
.onClick(() => this.launch());
|
2022-12-02 16:46:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async launch() {
|
2025-01-09 18:07:02 +02:00
|
|
|
if (this.launcherNote.isLabelTruthy("scriptInLauncherContent")) {
|
2022-12-17 21:46:51 +01:00
|
|
|
await this.launcherNote.executeScript();
|
|
|
|
} else {
|
2025-01-09 18:07:02 +02:00
|
|
|
const script = await this.launcherNote.getRelationTarget("script");
|
2025-01-11 01:46:00 +02:00
|
|
|
if (script) {
|
|
|
|
await script.executeScript();
|
|
|
|
}
|
2022-12-17 21:46:51 +01:00
|
|
|
}
|
2022-12-02 16:46:14 +01:00
|
|
|
}
|
2022-12-17 21:46:51 +01:00
|
|
|
}
|