Merge 7fbc09b2b8 into 34bdf0b4bf
This commit is contained in:
commit
baa94d135a
2 changed files with 42 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { VisibilityToggleCommand } from './commands/toggleVisibility';
|
||||
import { VisibilityToggleSetting } from './settings/hiddenToggle';
|
||||
import { SetDelaySetting } from './settings/setDelay';
|
||||
import { App, Plugin, PluginSettingTab, TFolder } from 'obsidian';
|
||||
import { ManageHiddenPaths } from './settings/manageHiddenPaths';
|
||||
import { changePathVisibility } from './utils';
|
||||
|
|
@ -7,6 +8,7 @@ import { changePathVisibility } from './utils';
|
|||
interface FileHiderSettings {
|
||||
hidden: boolean;
|
||||
hiddenList: string[];
|
||||
delay: number;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -14,6 +16,7 @@ export default class FileHider extends Plugin {
|
|||
settings: FileHiderSettings = {
|
||||
hidden: true,
|
||||
hiddenList: [],
|
||||
delay: 500, //set the default delay to 500
|
||||
};
|
||||
|
||||
style: CSSStyleSheet|null = null;
|
||||
|
|
@ -65,12 +68,12 @@ export default class FileHider extends Plugin {
|
|||
|
||||
this.app.workspace.onLayoutReady(() =>
|
||||
{
|
||||
// Timeout is used to delay until the file explorer is loaded. Delay of 0 works, but I set it to 200 just to be safe.
|
||||
// Use the delay setting from the plugin's settings. Default is 500.
|
||||
setTimeout(() => {
|
||||
for (const path of this.settings.hiddenList) {
|
||||
changePathVisibility(path, this.settings.hidden);
|
||||
};
|
||||
}, 200);
|
||||
}, this.settings.delay);
|
||||
});
|
||||
|
||||
new VisibilityToggleCommand(this);
|
||||
|
|
@ -126,5 +129,6 @@ class FileHiderSettingsTab extends PluginSettingTab {
|
|||
container.empty();
|
||||
VisibilityToggleSetting.create(this.plugin, container);
|
||||
ManageHiddenPaths.create(this.plugin, container);
|
||||
SetDelaySetting.create(this.plugin, container);
|
||||
};
|
||||
};
|
||||
36
src/settings/setDelay.ts
Normal file
36
src/settings/setDelay.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { Setting } from "obsidian";
|
||||
import FileHider from "../main";
|
||||
|
||||
export class SetDelaySetting {
|
||||
|
||||
public static create(plugin: FileHider, container: HTMLElement) {
|
||||
return new Setting(container)
|
||||
.setName(`Set Delay`)
|
||||
.setDesc(`Set the delay for hiding after the explorer loads. "X seconds Y milliseconds". Default: "0s 500ms".`)
|
||||
.addText(text => {
|
||||
// Convert milliseconds to seconds and milliseconds
|
||||
const seconds = Math.floor(plugin.settings.delay / 1000);
|
||||
const milliseconds = plugin.settings.delay % 1000;
|
||||
|
||||
text
|
||||
.setValue(`${seconds}s ${milliseconds}ms`)
|
||||
.onChange(value => {
|
||||
// Regular expression to match the input format "Xs Yms"
|
||||
const match = value.match(/(?:(\d+)s)?\s*(\d*)ms?/);
|
||||
if (match) {
|
||||
const seconds = parseInt(match[1] || "0", 10);
|
||||
const milliseconds = parseInt(match[2] || "0", 10);
|
||||
const delay = (seconds * 1000) + milliseconds;
|
||||
|
||||
if (!isNaN(delay)) {
|
||||
plugin.settings.delay = delay;
|
||||
plugin.saveSettings();
|
||||
};
|
||||
} else {
|
||||
// Handle invalid format input
|
||||
text.setValue(`${Math.floor(plugin.settings.delay / 1000)}s ${plugin.settings.delay % 1000}ms`);
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue