MCPcopy
hub / github.com/callumalpass/tasknotes / run

Method run

src/modals/taskModalSuggests.ts:210–253  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

208
209 private async getExistingUserFieldValues(fieldKey: string): Promise<string[]> {
210 const run = async (): Promise<string[]> => {
211 try {
212 const allFiles = this.plugin.app.vault.getMarkdownFiles();
213 const values = new Set<string>();
214
215 for (const file of allFiles) {
216 try {
217 const metadata = this.plugin.app.metadataCache.getFileCache(file);
218 const frontmatter = metadata?.frontmatter;
219
220 if (frontmatter && frontmatter[fieldKey] !== undefined) {
221 const value = frontmatter[fieldKey];
222
223 if (Array.isArray(value)) {
224 value.forEach((item) => {
225 if (typeof item === "string" && item.trim()) {
226 values.add(item.trim());
227 }
228 });
229 } else if (typeof value === "string" && value.trim()) {
230 values.add(value.trim());
231 } else if (typeof value === "number" || typeof value === "boolean") {
232 values.add(value.toString());
233 }
234 }
235
236 if (values.size >= 200) {
237 break;
238 }
239 } catch {
240 continue;
241 }
242 }
243
244 return Array.from(values).sort();
245 } catch (error) {
246 tasknotesLogger.error("Error getting user field values:", {
247 category: "persistence",
248 operation: "getting-user-field-values",
249 error: error,
250 });
251 return [];
252 }
253 };
254
255 const debounceMs = this.plugin.settings?.suggestionDebounceMs ?? 0;
256 if (!debounceMs) {

Callers

nothing calls this directly

Calls 4

getMarkdownFilesMethod · 0.80
getFileCacheMethod · 0.80
errorMethod · 0.80
toStringMethod · 0.65

Tested by

no test coverage detected