Skip to content

Commit

Permalink
snap: perf mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinslin committed Jul 6, 2023
1 parent d7b3537 commit 30d3ea1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/common-all/src/constants/configs/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,8 @@ export const WORKSPACE: DendronConfigEntryCollection<DendronWorkspaceConfig> = {
label: "Main Vault",
desc: "Main vault",
},
enablePerfMode: {
label: "Enable Performance Mode",
desc: "Performance mode turns off features like backlink refresh to improve performance",
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type DendronWorkspaceConfig = {
metadataStore?: "sqlite" | "json";
enablePersistentHistory?: boolean;
mainVault?: string;
enablePerfMode?: boolean;
};

export type DendronSeedEntry = {
Expand Down
18 changes: 13 additions & 5 deletions packages/plugin-core/src/features/BacklinksTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
BacklinkPanelSortOrder,
DateFormatUtil,
DendronASTDest,
DendronConfig,
EngineEventEmitter,
NoteUtils,
ProcFlavor,
Expand Down Expand Up @@ -66,11 +67,8 @@ export default class BacklinksTreeDataProvider
* @param engineEvents - specifies when note state has been changed on the
* engine
*/
constructor(
engineEvents: EngineEventEmitter,
isLinkCandidateEnabled: boolean | undefined
) {
this._isLinkCandidateEnabled = isLinkCandidateEnabled;
constructor(engineEvents: EngineEventEmitter, config: DendronConfig) {
this._isLinkCandidateEnabled = config.dev?.enableLinkCandidates;

// Set default sort order to use last updated
this.sortOrder =
Expand All @@ -83,6 +81,16 @@ export default class BacklinksTreeDataProvider

this.onDidChangeTreeData = this._onDidChangeTreeDataEmitter.event;
this._engineEvents = engineEvents;

if (config.workspace.enablePerfMode) {
const ctx = "BacklinksTreeDataProvider.cons";
Logger.info({
ctx,
msg: "perf mode enabled, not subscribing to backlink updates",
});
return;
}

this.setupSubscriptions();
}

Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-core/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,11 @@ export class DendronExtension implements IDendronExtension {
private setupBacklinkTreeView() {
const ctx = "setupBacklinkTreeView";
Logger.info({ ctx, msg: "init:backlinks" });
const config = this.getDWorkspace().config;

const backlinksTreeDataProvider = new BacklinksTreeDataProvider(
this.getEngine(),
this.getDWorkspace().config.dev?.enableLinkCandidates
config
);

const backlinkTreeView = vscode.window.createTreeView(
Expand Down
1 change: 1 addition & 0 deletions test-workspace/dendron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ workspace:
enableRemoteVaultInit: true
workspaceVaultSyncMode: noCommit
enableAutoFoldFrontmatter: false
enablePerfMode: true
maxPreviewsCached: 10
maxNoteLength: 204800
task:
Expand Down

0 comments on commit 30d3ea1

Please sign in to comment.