Skip to content

Commit 958c51b

Browse files
authored
Merge pull request #675 from callumalpass/fix-project-field-mapping-main
Fix project/subtask functionality to respect user field mapping
2 parents e4b8803 + 8e32d78 commit 958c51b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/services/ProjectSubtasksService.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,12 @@ export class ProjectSubtasksService {
112112
if (!(sourceFile instanceof TFile)) return false;
113113

114114
const metadata = this.plugin.app.metadataCache.getFileCache(sourceFile);
115-
if (!metadata?.frontmatter?.projects) return false;
116115

117-
const projects = metadata.frontmatter.projects;
116+
// Use the user's configured field mapping for projects
117+
const projectsFieldName = this.plugin.fieldMapper.toUserField('projects');
118+
if (!metadata?.frontmatter?.[projectsFieldName]) return false;
119+
120+
const projects = metadata.frontmatter[projectsFieldName];
118121
if (!Array.isArray(projects)) return false;
119122

120123
// Check if any project reference resolves to our target
@@ -172,7 +175,10 @@ export class ProjectSubtasksService {
172175

173176
// Check if source has projects frontmatter
174177
const metadata = this.plugin.app.metadataCache.getCache(sourcePath);
175-
const projects = metadata?.frontmatter?.projects;
178+
179+
// Use the user's configured field mapping for projects
180+
const projectsFieldName = this.plugin.fieldMapper.toUserField('projects');
181+
const projects = metadata?.frontmatter?.[projectsFieldName];
176182

177183
if (Array.isArray(projects) && projects.some((p: any) =>
178184
typeof p === 'string' && p.startsWith('[[') && p.endsWith(']]')

src/utils/MinimalNativeCache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ export class MinimalNativeCache extends Events {
619619
if (!metadata?.frontmatter || !this.isTaskFile(metadata.frontmatter)) continue;
620620

621621
// Check if this task has projects field with wikilinks
622-
const projectsField = metadata.frontmatter.projects;
622+
const projectsFieldName = this.fieldMapper?.toUserField('projects') || 'projects';
623+
const projectsField = metadata.frontmatter[projectsFieldName];
623624
if (!Array.isArray(projectsField)) continue;
624625

625626
// Check if projects field contains wikilinks (not just plain text)

0 commit comments

Comments
 (0)