shumadrid_obsidian-git-chan.../src/settings/ui/ChangelogStatsInFileExplorerOptions.ts
2025-03-12 00:52:52 +01:00

33 lines
1.2 KiB
TypeScript

import { GitChangelogSetting } from 'settings/components/setting.ts';
import { DEFAULT_SETTINGS } from 'settings/settings.ts';
import { FileExplorerStats } from 'types.ts';
export class ChangelogStatsInFileExplorerOptions extends GitChangelogSetting {
public display(): void {
this.createSetting()
.setName('Show changelog stats in File Explorer')
.addDropdown((dropdown) => {
const options: Record<FileExplorerStats, string> = {
Disabled: 'Disabled',
Folders: 'Folders',
FoldersAndNotes: 'Notes'
};
dropdown.addOptions(options);
dropdown.setValue(
this.plugin.settings.fileExplorerStats ??
DEFAULT_SETTINGS.fileExplorerStats
);
dropdown.onChange((value: string) => {
const option =
FileExplorerStats[value as keyof typeof FileExplorerStats];
this.refreshDisplaySmooth(0);
const newSettings = this.plugin.settingsClone;
newSettings.fileExplorerStats = option;
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.plugin.saveSettings(newSettings);
});
});
}
}