Skip to content

Commit

Permalink
fix: auto theme not following Obsidian theme (#284)
Browse files Browse the repository at this point in the history
Closes #136 and #274
  • Loading branch information
The-Noah authored Oct 20, 2024
1 parent b7811fb commit 3085a3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/baseMapView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,14 @@ export abstract class BaseMapView extends ItemView {
isDarkMode(settings: PluginSettings): boolean {
if (settings.chosenMapMode === 'dark') return true;
if (settings.chosenMapMode === 'light') return false;

// Auto mode - check if the theme is dark
if ((this.app.vault as any).getConfig('theme') === 'obsidian')
return true;
const theme = (this.app.vault as any).getConfig('theme');
if (theme === 'obsidian') return true;
else if (theme === 'moonstone') return false;
else if (theme === 'system')
return !document.body.classList.contains('theme-light');

return false;
}

Expand Down
9 changes: 7 additions & 2 deletions src/mapContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,14 @@ export class MapContainer {
isDarkMode(settings: PluginSettings): boolean {
if (settings.chosenMapMode === 'dark') return true;
if (settings.chosenMapMode === 'light') return false;

// Auto mode - check if the theme is dark
if ((this.app.vault as any).getConfig('theme') === 'obsidian')
return true;
const theme = (this.app.vault as any).getConfig('theme');
if (theme === 'obsidian') return true;
else if (theme === 'moonstone') return false;
else if (theme === 'system')
return !document.body.classList.contains('theme-light');

return false;
}

Expand Down

0 comments on commit 3085a3e

Please sign in to comment.