Refactor VaultAdapter.ts and AppUtils.ts

This commit is contained in:
kitelev 2025-01-03 11:22:23 +05:00
parent 36fb218170
commit 6d5a4c1266
5 changed files with 4 additions and 4 deletions

View File

@ -12,7 +12,6 @@ export default class CreateEffortUnderAreaExoCommand implements ExoCommand {
async execute() { async execute() {
const activeFile = this.ctx.appUtils.getActiveFileOrThrow(); const activeFile = this.ctx.appUtils.getActiveFileOrThrow();
const activeKo = this.ctx.kObjectCreator.createFromTFileTyped(activeFile); const activeKo = this.ctx.kObjectCreator.createFromTFileTyped(activeFile);
if (!(activeKo instanceof Area)) { if (!(activeKo instanceof Area)) {
throw new Error("Active file is not an Area"); throw new Error("Active file is not an Area");
} }

View File

@ -7,7 +7,7 @@ export default class OpenRandomNoteExoCommand implements ExoCommand {
slug = "open-random-note"; slug = "open-random-note";
async execute(ctx: ExoContext): Promise<void> { async execute(ctx: ExoContext): Promise<void> {
const files = ctx.vaultAdapter.getAllMdFiles(); const files = ctx.appUtils.getAllMdFiles();
const today = new Date(); const today = new Date();
const lastMonth = new Date(today.getFullYear(), today.getMonth() - 1, today.getDate()).setHours(0, 0, 0, 0); // Дата месяц назад без времени const lastMonth = new Date(today.getFullYear(), today.getMonth() - 1, today.getDate()).setHours(0, 0, 0, 0); // Дата месяц назад без времени

View File

@ -16,7 +16,7 @@ export default class EffortPersistenceAdapter implements EffortRepository {
// TODO should be in EffortPathRulesHelper in app module // TODO should be in EffortPathRulesHelper in app module
getPathForCreate(effort: Effort): string { getPathForCreate(effort: Effort): string {
if (effort.area !== null) { if (effort.area !== null) {
const areaFile = this.ctx.vaultAdapter.getObjectFileOrThrow(effort.area); const areaFile = this.ctx.appUtils.getObjectFileOrThrow(effort.area);
const areaFolder = areaFile.parent; const areaFolder = areaFile.parent;
if (!areaFolder) { if (!areaFolder) {
throw new Error("Area file has no parent folder"); throw new Error("Area file has no parent folder");

View File

@ -5,7 +5,7 @@ export default class KObjectUtility {
} }
async addMissingId(): Promise<void> { async addMissingId(): Promise<void> {
let allMdFiles = this.ctx.vaultAdapter.getAllMdFiles(); let allMdFiles = this.ctx.appUtils.getAllMdFiles();
const KOs = allMdFiles.filter(f => { const KOs = allMdFiles.filter(f => {
const tags = this.ctx.appUtils.getTagsFromFile(f); const tags = this.ctx.appUtils.getTagsFromFile(f);

View File

@ -15,6 +15,7 @@ export default class CreateEffortService implements CreateEffortUseCase {
const effort = new Effort(id, title, EffortStatus.DRAFT, null, null, area); const effort = new Effort(id, title, EffortStatus.DRAFT, null, null, area);
this.effortRepository.save(effort); this.effortRepository.save(effort);
return effort; return effort;
} }