Skip to content

Commit a802506

Browse files
refactor: clean up main.ts and events.ts for improved readability and consistency
1 parent 6bfe341 commit a802506

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export default class clusterPlugin extends Plugin {
1010
console.log("loading Cluster plugin");
1111

1212
await this.loadSettings();
13-
1413
this.addSettingTab(new settingTab(this.app, this));
1514

1615
// UN-SORTED Folder Styling
@@ -19,8 +18,7 @@ export default class clusterPlugin extends Plugin {
1918
await P.unSortedObserver(this.app);
2019
}, 1000);
2120

22-
await P.cardStyleFunction( this.settings);//card style for lorens theme
23-
21+
2422
const file = this.app.workspace.getActiveFile() as TFile;
2523
if (file) {
2624
await P.buttonsLine(this.app, file, this.settings);
@@ -29,6 +27,8 @@ export default class clusterPlugin extends Plugin {
2927
P.addRibbonIcon( this);
3028
P.fileMenu(this,P.SimpleFocus);
3129
P.addCommands(this);
30+
31+
await P.cardStyleFunction( this.settings);//card style for lorens theme
3232
}
3333

3434
async loadSettings() {

src/mainParts/events.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import { Plugin, TFile } from "obsidian";
2+
import { clusterPluginSettings } from "src/settings/settings";
23
import P from "src/util/P";
34

4-
export function addEvents(plugin: Plugin) {
5+
interface ExtendedPlugin extends Plugin {
6+
settings: clusterPluginSettings;
7+
}
8+
export function addEvents(plugin: ExtendedPlugin) {
59
// watch if file opened
610
plugin.registerEvent(
7-
this.app.workspace.on("file-open", async (file: TFile) => {
11+
plugin.app.workspace.on("file-open", async (file: TFile) => {
812
if (file) {
9-
await P.buttonsLine(this.app, file, this.settings); // Add Cluster Buttons
10-
await P.coloringTreePanel(this.app, file);
11-
this.settings.foldProperties ? await P.foldPropertiesElement(this.app, file) : null; // Fold Properties
12-
await P.addUnsortedFilesCounter(this.app);
13-
await P.unSortedObserver(this.app);
13+
await P.buttonsLine(plugin.app, file, plugin.settings); // Add Cluster Buttons
14+
await P.coloringTreePanel(plugin.app, file);
15+
plugin.settings.foldProperties ? await P.foldPropertiesElement(plugin.app, file) : null; // Fold Properties
16+
await P.addUnsortedFilesCounter(plugin.app);
17+
await P.unSortedObserver(plugin.app);
1418
}
1519
}),
1620
);

0 commit comments

Comments
 (0)