Merge pull request #44 from devonthesofa/chore/performance-setting

feat: disable dashboard and grouped views for large vaults (workaround for performance issues)
This commit is contained in:
Aleix Soler 2025-07-23 08:44:17 +02:00 committed by GitHub
commit 070df7d3e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 77 additions and 2 deletions

View file

@ -52,6 +52,21 @@ export const BehaviourSettings: React.FC<Props> = ({ settings, onChange }) => {
}
/>
</SettingItem>
<SettingItem
name="Vault size limit"
description="Disable dashboard and grouped view for vaults with more notes than this limit to improve performance. Set to 0 to disable this feature."
>
<input
type="number"
min="0"
value={settings.vaultSizeLimit || 15000}
onChange={(e) => {
const value = parseInt(e.target.value) || 15000;
onChange("vaultSizeLimit", value);
}}
/>
</SettingItem>
</div>
);
};

View file

@ -27,4 +27,5 @@ export const DEFAULT_PLUGIN_SETTINGS: PluginSettings = {
statusBarNoStatusText: "No status",
statusBarShowNoStatusIcon: false,
statusBarShowNoStatusText: true,
vaultSizeLimit: 15000, // Disable dashboard and grouped view for vaults with more notes than this limit
};

View file

@ -151,7 +151,8 @@ export class GroupedStatusView extends ItemView {
key === "useCustomStatusesOnly" ||
key === "customStatuses" ||
key === "useMultipleStatuses" ||
key === "strictStatuses"
key === "strictStatuses" ||
key === "vaultSizeLimit"
) {
onDataChange();
}
@ -181,6 +182,19 @@ export class GroupedStatusView extends ItemView {
container.empty();
container.addClass("grouped-status-view-container");
// Check if vault exceeds the size limit
const files = BaseNoteStatusService.app.vault.getMarkdownFiles();
const vaultSizeLimit = settingsService.settings.vaultSizeLimit || 15000;
if (vaultSizeLimit > 0 && files.length > vaultSizeLimit) {
// Show disabled message
container.createEl("div", {
cls: "grouped-status-view-disabled",
text: `Grouped Status View disabled: Vault has ${files.length} notes (limit: ${vaultSizeLimit}). You can adjust this limit in plugin settings.`,
});
return;
}
this.root = createRoot(container);
this.root.render(
<GroupedStatusViewComponent

View file

@ -304,6 +304,19 @@ export class StatusDashboardView extends ItemView {
container.empty();
container.addClass("status-dashboard-view-container");
// Check if vault exceeds the size limit
const files = this.app.vault.getMarkdownFiles();
const vaultSizeLimit = settingsService.settings.vaultSizeLimit || 15000;
if (vaultSizeLimit > 0 && files.length > vaultSizeLimit) {
// Show disabled message
container.createEl("div", {
cls: "status-dashboard-disabled",
text: `Dashboard disabled: Vault has ${files.length} notes (limit: ${vaultSizeLimit}). You can adjust this limit in plugin settings.`,
});
return;
}
this.root = createRoot(container);
// Set up event listeners
@ -334,7 +347,8 @@ export class StatusDashboardView extends ItemView {
key === "useCustomStatusesOnly" ||
key === "customStatuses" ||
key === "useMultipleStatuses" ||
key === "strictStatuses"
key === "strictStatuses" ||
key === "vaultSizeLimit"
) {
handleVaultChange();
handleFileChange();

View file

@ -310,6 +310,21 @@
color: var(--text-muted);
}
.status-dashboard-disabled {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
padding: var(--size-4-4);
text-align: center;
font-size: var(--font-ui-medium);
color: var(--text-muted);
background: var(--background-secondary);
border: 2px dashed var(--background-modifier-border);
border-radius: var(--radius-m);
margin: var(--size-4-4);
}
/* Scrollbar */
.status-dashboard-content::-webkit-scrollbar {
width: var(--scrollbar-width);

View file

@ -210,6 +210,21 @@
font-size: var(--font-ui-medium);
}
.grouped-status-view-disabled {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
padding: var(--size-4-4);
text-align: center;
font-size: var(--font-ui-medium);
color: var(--text-muted);
background: var(--background-secondary);
border: 2px dashed var(--background-modifier-border);
border-radius: var(--radius-m);
margin: var(--size-4-4);
}
/* Scrollbar */
.grouped-status-content::-webkit-scrollbar,
.grouped-status-files-list::-webkit-scrollbar {

View file

@ -30,5 +30,6 @@ export type PluginSettings = {
statusBarNoStatusText: string; // Custom text for status bar when no status
statusBarShowNoStatusIcon: boolean; // Whether to show icon in status bar for no status
statusBarShowNoStatusText: boolean; // Whether to show text in status bar for no status
vaultSizeLimit: number; // Disable dashboard and grouped view for vaults with more notes than this limit
[key: string]: unknown;
};