Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 1x 1x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 6x 6x 8x 9x 4x 4x 4x 4x 4x 4x 4x 9x 8x | import { App, Modal } from "obsidian";
import type { ModelInfo } from "../types";
export class ConfirmPullModal extends Modal {
private model: ModelInfo;
private _resolve: ((value: boolean) => void) | null = null;
private decided = false;
readonly result: Promise<boolean>;
constructor(app: App, model: ModelInfo) {
super(app);
this.model = model;
this.result = new Promise<boolean>((resolve) => {
this._resolve = resolve;
});
}
onOpen(): void {
const { contentEl } = this;
contentEl.empty();
contentEl.addClass("lilbee-confirm-pull");
contentEl.createEl("h2", { text: "Download model?" });
const info = contentEl.createDiv({ cls: "lilbee-confirm-pull-info" });
info.createEl("p", { text: `Model: ${this.model.name}` });
info.createEl("p", { text: `Size: ${this.model.size_gb} GB` });
info.createEl("p", { text: `Minimum RAM: ${this.model.min_ram_gb} GB` });
const actions = contentEl.createDiv({ cls: "lilbee-confirm-pull-actions" });
const pullBtn = actions.createEl("button", {
text: "Pull Model",
cls: "mod-cta",
});
pullBtn.addEventListener("click", () => this.decide(true));
const cancelBtn = actions.createEl("button", { text: "Cancel" });
cancelBtn.addEventListener("click", () => this.decide(false));
}
onClose(): void {
this.decide(false);
}
private decide(confirmed: boolean): void {
if (this.decided) return;
this.decided = true;
if (this._resolve) {
const resolve = this._resolve;
this._resolve = null;
resolve(confirmed);
}
this.close();
}
}
|