Skip to content

Commit

Permalink
Simplification of this.app ==> app - this is a globally exposed object
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianMC committed Aug 23, 2023
1 parent 150b864 commit b752662
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ export default class CustomSortPlugin extends Plugin {
}

readAndParseSortingSpec() {
const mCache: MetadataCache = this.app.metadataCache
const mCache: MetadataCache = app.metadataCache
let failed: boolean = false
let anySortingSpecFound: boolean = false
let errorMessage: string | null = null
// reset cache
this.sortSpecCache = null
const processor: SortingSpecProcessor = new SortingSpecProcessor()

Vault.recurseChildren(this.app.vault.getRoot(), (file: TAbstractFile) => {
Vault.recurseChildren(app.vault.getRoot(), (file: TAbstractFile) => {
if (failed) return
if (file instanceof TFile) {
const aFile: TFile = file as TFile
Expand Down Expand Up @@ -245,7 +245,7 @@ export default class CustomSortPlugin extends Plugin {
this.ribbonIconStateInaccurate = true
}

this.addSettingTab(new CustomSortSettingTab(this.app, this));
this.addSettingTab(new CustomSortSettingTab(app, this));

this.registerEventHandlers()

Expand All @@ -258,7 +258,7 @@ export default class CustomSortPlugin extends Plugin {
const plugin: CustomSortPlugin = this
this.registerEvent(
// Keep in mind: this event is triggered once after app starts and then after each modification of _any_ metadata
this.app.metadataCache.on("resolved", () => {
app.metadataCache.on("resolved", () => {
if (!this.settings.suspended) {
if (!this.initialAutoOrManualSortingTriggered) {
this.readAndParseSortingSpec()
Expand Down Expand Up @@ -304,7 +304,7 @@ export default class CustomSortPlugin extends Plugin {
}

initialize() {
this.app.workspace.onLayoutReady(() => {
app.workspace.onLayoutReady(() => {
this.fileExplorerFolderPatched = this.patchFileExplorerFolder();
})
}
Expand Down Expand Up @@ -365,7 +365,7 @@ export default class CustomSortPlugin extends Plugin {

// Credits go to https://github.com/nothingislost/obsidian-bartender
getFileExplorer(): FileExplorerView | undefined {
let fileExplorer: FileExplorerView | undefined = this.app.workspace.getLeavesOfType("file-explorer")?.first()
let fileExplorer: FileExplorerView | undefined = app.workspace.getLeavesOfType("file-explorer")?.first()
?.view as unknown as FileExplorerView;
return fileExplorer;
}
Expand Down

0 comments on commit b752662

Please sign in to comment.