Small refactoring
This commit is contained in:
parent
2f0a745248
commit
1158fdade9
|
@ -18,7 +18,7 @@ export default class EffortPersistenceAdapter implements EffortRepository {
|
|||
async update(effort: Effort): Promise<void> {
|
||||
const file = this.ctx.appUtils.getObjectFileOrThrow(effort);
|
||||
const data = this.serializeData(effort);
|
||||
await this.ctx.app.vault.modify(file, data);
|
||||
await this.ctx.appUtils.updateFile(file, data);
|
||||
}
|
||||
|
||||
private serializeData(effort: Effort) {
|
||||
|
|
|
@ -6,7 +6,12 @@ export default class AppUtils {
|
|||
}
|
||||
|
||||
async createFile(path: string, textContent: string) {
|
||||
let file = await this.app.vault.create(path, textContent);
|
||||
const file = await this.app.vault.create(path, textContent);
|
||||
await this.waitCacheUpdate(file);
|
||||
}
|
||||
|
||||
async updateFile(file: TFile, data: string) {
|
||||
await this.app.vault.modify(file, data);
|
||||
await this.waitCacheUpdate(file);
|
||||
}
|
||||
|
||||
|
@ -83,11 +88,11 @@ export default class AppUtils {
|
|||
return [];
|
||||
}
|
||||
|
||||
|
||||
getFileByName(parentFileName: string): TFile {
|
||||
return this.app.vault.getMarkdownFiles().filter(f => f.name == parentFileName)[0];
|
||||
}
|
||||
|
||||
|
||||
getAllMdFiles() {
|
||||
return this.app.vault.getMarkdownFiles();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue