mirror of
https://github.com/jacobtread/obsidian-timekeep.git
synced 2026-07-22 10:10:27 +00:00
refactor: move pickFileName to a static member pick on
FileNamePromptModal
This commit is contained in:
parent
45fb437e85
commit
0a181ecf2e
2 changed files with 8 additions and 8 deletions
|
|
@ -4,7 +4,7 @@ import { App, Notice, Platform } from "obsidian";
|
|||
import { createPdfExport, createPdfExportBlob } from "@/components/pdf/renderer";
|
||||
import { TimekeepSettings, PdfExportBehavior } from "@/settings";
|
||||
import { Timekeep } from "@/timekeep/schema";
|
||||
import { pickFileName } from "@/views/file-name-prompt-modal";
|
||||
import { FileNamePromptModal } from "@/views/file-name-prompt-modal";
|
||||
|
||||
export async function exportPdf(app: App, timekeep: Timekeep, settings: TimekeepSettings) {
|
||||
if (Platform.isMobileApp) {
|
||||
|
|
@ -18,7 +18,7 @@ async function exportPdfMobile(app: App, timekeep: Timekeep, settings: TimekeepS
|
|||
const currentTime = moment();
|
||||
const blob = await createPdfExportBlob(timekeep, settings, currentTime);
|
||||
const buffer = await blob.arrayBuffer();
|
||||
const fileName = await pickFileName(app);
|
||||
const fileName = await FileNamePromptModal.pick(app);
|
||||
|
||||
if (!fileName) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,12 @@ export class FileNamePromptModal extends Modal {
|
|||
this.callback = callback;
|
||||
}
|
||||
|
||||
static pick(app: App): Promise<string | null> {
|
||||
return new Promise((resolve) => {
|
||||
new FileNamePromptModal(app, resolve).open();
|
||||
});
|
||||
}
|
||||
|
||||
onOpen(): void {
|
||||
const { contentEl } = this;
|
||||
contentEl.createEl("p", { text: "Enter name to save the exported PDF file as:" });
|
||||
|
|
@ -50,9 +56,3 @@ export class FileNamePromptModal extends Modal {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function pickFileName(app: App): Promise<string | null> {
|
||||
return new Promise((resolve) => {
|
||||
new FileNamePromptModal(app, resolve).open();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue