I am using the code below to search for tasks but the issue is that it opens the seach ui every time it does… I want it to happen in the background. Anyone have a way to do this better while using the Query Language of Obsidian?
async function getTaskBadgeCountSearch2(app) {
const taskQuery = `tasks not done due today path does not include 50 Resources group by path sort by priority sort by path hide due date `;
app.internalPlugins.plugins['global-search'].instance.openGlobalSearch(taskQuery);
const searchLeaf = app.workspace.getLeavesOfType('search')[0];
const search = await searchLeaf.open(searchLeaf.view);
return await new Promise(resolve => setTimeout(() => {
resolve(search.dom.resultDomLookup.size);
}, 300)); // the delay here was specified in 'obsidian-text-expand' plugin; I assume they had a reason
}