Skip to content

Commit

Permalink
1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
alangrainger committed Aug 8, 2024
1 parent f2ec132 commit 0bdafe3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "lazy-plugins",
"name": "Lazy Plugin Loader",
"version": "1.0.4",
"version": "1.0.5",
"minAppVersion": "1.6.0",
"description": "Load plugins with a delay on startup, so that you can get your app startup down into the sub-second loading time.",
"author": "Alan Grainger",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lazy-plugins",
"version": "1.0.4",
"version": "1.0.5",
"description": "Load plugins with a delay on startup, so that you can get your app startup down into the sub-second loading time.",
"main": "main.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ export default class LazyPlugin extends Plugin {
} else {
// Start with a delay
const seconds = startupType === LoadingMethod.short ? this.settings.shortDelaySeconds : this.settings.longDelaySeconds
// Add a short additional delay to each plugin, for two purposes:
// 1. Have them load in a consistent order, which helps them appear in the sidebar in the same order
// 2. Stagger them slightly so there's not a big slowdown when they all fire at once
const delay = this.manifests.findIndex(x => x.id === pluginId) * 40
const timeout = setTimeout(async () => {
if (!obsidian.plugins?.[pluginId]?._loaded) {
if (this.settings.showConsoleLog) {
console.log(`Starting ${pluginId} after a ${startupType} delay`)
}
await obsidian.enablePlugin(pluginId)
}
}, seconds * 1000 + Math.random() * 100)
}, seconds * 1000 + delay)
// Store the timeout so we can cancel it later if needed during plugin unload
this.pendingTimeouts.push(timeout)
}
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"1.0.1": "1.6.0",
"1.0.2": "1.6.0",
"1.0.3": "1.6.0",
"1.0.4": "1.6.0"
"1.0.4": "1.6.0",
"1.0.5": "1.6.0"
}

0 comments on commit 0bdafe3

Please sign in to comment.