Skip to content

Commit ba9f6e6

Browse files
authored
refactor: simplify Cache.indexFile() (#1017)
* refactor: Flip if-else Automated refactoring, done by WebStorm * refactor: Remove unused assignment Automated refactoring, done by WebStorm (GitHook disabled, so I can show the working with WebStorm) * refactor: Convert let to const Automated refactoring, done by WebStorm * refactor: Make fileContent const, for clarity. Manual refactoring. * refactor: Remove empty else block Manual refactoring
1 parent 4f189cb commit ba9f6e6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/Cache.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,14 @@ export class Cache {
205205
return task.path === file.path;
206206
});
207207

208-
let listItems = fileCache.listItems;
209-
let fileContent = '';
208+
const listItems = fileCache.listItems;
209+
// When there is no list items cache, there are no tasks.
210+
// Still continue to notify watchers of removal.
211+
210212
let newTasks: Task[] = [];
211-
if (listItems === undefined) {
212-
// When there is no list items cache, there are no tasks.
213-
// Still continue to notify watchers of removal.
214-
listItems = [];
215-
} else {
213+
if (listItems !== undefined) {
216214
// Only read the file and process for tasks if there are list items.
217-
fileContent = await this.vault.cachedRead(file);
215+
const fileContent = await this.vault.cachedRead(file);
218216
newTasks = Cache.getTasksFromFileContent(
219217
fileContent,
220218
listItems,

0 commit comments

Comments
 (0)