generated from tpl/obsidian-sample-plugin
31 lines
733 B
TypeScript
31 lines
733 B
TypeScript
import RatingModalView from "./RatingModalView.svelte";
|
|
import { App } from "obsidian";
|
|
import { SvelteModal } from "./SvelteModal";
|
|
|
|
export class RatingModal extends SvelteModal<typeof RatingModalView> {
|
|
constructor(
|
|
app: App,
|
|
spiceConfigured: boolean,
|
|
onSubmit: (rating: number, spice: number) => void = () => {}
|
|
) {
|
|
super(app, RatingModalView, { props: { spiceConfigured, onSubmit } });
|
|
}
|
|
|
|
static createAndOpen(
|
|
app: App,
|
|
spiceConfigured: boolean
|
|
): Promise<{ rating: number; spice: number }> {
|
|
return new Promise((resolve) => {
|
|
const modal = new RatingModal(
|
|
app,
|
|
spiceConfigured,
|
|
(rating, spice) => {
|
|
modal.close();
|
|
resolve({ rating, spice });
|
|
}
|
|
);
|
|
modal.open();
|
|
});
|
|
}
|
|
}
|