Skip to content

Commit

Permalink
fix: dark mode not adapted when first init the vault
Browse files Browse the repository at this point in the history
  • Loading branch information
nhannht committed Jul 30, 2024
1 parent 986ff08 commit 9dfb2a7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default class SmartGanttPlugin extends Plugin {
this.app.workspace.iterateCodeMirrors(cm => cm.setOption("mode", cm.getOption("mode")))
}

darkModeAdapt = ()=>{
if (document.body.hasClass("theme-dark")){
darkModeAdapt = () => {
if (document.body.hasClass("theme-dark")) {
document.body.addClass("dark")
} else {
document.body.removeClass("dark")
Expand All @@ -40,6 +40,8 @@ export default class SmartGanttPlugin extends Plugin {


override async onload() {
this.darkModeAdapt()

await this.settingManager.loadSettings()

this.app.workspace.onLayoutReady(() => {
Expand Down Expand Up @@ -92,7 +94,7 @@ export default class SmartGanttPlugin extends Plugin {
await this.ganttBlockManager.registerTaskListBlock()


this.registerEvent(this.app.workspace.on('css-change',this.darkModeAdapt))
this.registerEvent(this.app.workspace.on('css-change', this.darkModeAdapt))


// This adds a settings tab so the user can configure various aspects of the plugin
Expand All @@ -113,7 +115,7 @@ export default class SmartGanttPlugin extends Plugin {
this.refreshLeaves()

}
this.app.workspace.off('css-change',this.darkModeAdapt)
this.app.workspace.off('css-change', this.darkModeAdapt)

}

Expand Down

0 comments on commit 9dfb2a7

Please sign in to comment.