Refactor VaultAdapter.ts and AppUtils.ts
This commit is contained in:
parent
36fb218170
commit
6d5a4c1266
|
@ -12,7 +12,6 @@ export default class CreateEffortUnderAreaExoCommand implements ExoCommand {
|
|||
async execute() {
|
||||
const activeFile = this.ctx.appUtils.getActiveFileOrThrow();
|
||||
const activeKo = this.ctx.kObjectCreator.createFromTFileTyped(activeFile);
|
||||
|
||||
if (!(activeKo instanceof Area)) {
|
||||
throw new Error("Active file is not an Area");
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ export default class OpenRandomNoteExoCommand implements ExoCommand {
|
|||
slug = "open-random-note";
|
||||
|
||||
async execute(ctx: ExoContext): Promise<void> {
|
||||
const files = ctx.vaultAdapter.getAllMdFiles();
|
||||
const files = ctx.appUtils.getAllMdFiles();
|
||||
const today = new Date();
|
||||
const lastMonth = new Date(today.getFullYear(), today.getMonth() - 1, today.getDate()).setHours(0, 0, 0, 0); // Дата месяц назад без времени
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ export default class EffortPersistenceAdapter implements EffortRepository {
|
|||
// TODO should be in EffortPathRulesHelper in app module
|
||||
getPathForCreate(effort: Effort): string {
|
||||
if (effort.area !== null) {
|
||||
const areaFile = this.ctx.vaultAdapter.getObjectFileOrThrow(effort.area);
|
||||
const areaFile = this.ctx.appUtils.getObjectFileOrThrow(effort.area);
|
||||
const areaFolder = areaFile.parent;
|
||||
if (!areaFolder) {
|
||||
throw new Error("Area file has no parent folder");
|
||||
|
|
|
@ -5,7 +5,7 @@ export default class KObjectUtility {
|
|||
}
|
||||
|
||||
async addMissingId(): Promise<void> {
|
||||
let allMdFiles = this.ctx.vaultAdapter.getAllMdFiles();
|
||||
let allMdFiles = this.ctx.appUtils.getAllMdFiles();
|
||||
|
||||
const KOs = allMdFiles.filter(f => {
|
||||
const tags = this.ctx.appUtils.getTagsFromFile(f);
|
||||
|
|
|
@ -15,6 +15,7 @@ export default class CreateEffortService implements CreateEffortUseCase {
|
|||
const effort = new Effort(id, title, EffortStatus.DRAFT, null, null, area);
|
||||
|
||||
this.effortRepository.save(effort);
|
||||
|
||||
return effort;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue