Skip to content

Commit

Permalink
Remove delay setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangomba committed Nov 22, 2022
1 parent 048c618 commit 020dbeb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
10 changes: 4 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ export default class MyPlugin extends Plugin {
await this.saveData(this.settings);
}

_onEditorChange = async (editor: Editor, _markdownView: MarkdownView) => {
// Settings can change while the editor is open, so we need to reload them.
await this.loadSettings();
setTimeout(() => {
this._sortTodos(editor);
}, this.settings.delayMS);
_onEditorChange = (editor: Editor, _markdownView: MarkdownView) => {
this._sortTodos(editor);
};

_lastSort = new Date();
Expand All @@ -43,6 +39,8 @@ export default class MyPlugin extends Plugin {
console.error("WARNING!!! Possible infinite sort detected");
return;
}
// Settings can change while the editor is open, so we need to reload them.
await this.loadSettings();
const cursor = editor.getCursor();
const lineNumber = cursor.line;
const result = sortTodos(value, this.settings.sortOrder);
Expand Down
16 changes: 0 additions & 16 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import { SortOrder } from "./sort";

export interface Settings {
sortOrder: SortOrder;
delayMS: number;
}

export const DEFAULT_SETTINGS: Settings = {
sortOrder: SortOrder.COMPLETED_TOP,
delayMS: 0,
};

export class SettingsTab extends PluginSettingTab {
Expand All @@ -34,19 +32,5 @@ export class SettingsTab extends PluginSettingTab {
await this.plugin.saveSettings();
})
);
new Setting(containerEl)
.setName("Delay")
.setDesc("How long to wait after a change until sorting todos?")
.addDropdown((dropdown) =>
dropdown
.addOption("0", "No delay")
.addOption("125", "125ms")
.addOption("250", "250ms")
.setValue(this.plugin.settings.delayMS.toString())
.onChange(async (val) => {
this.plugin.settings.delayMS = parseInt(val, 10);
await this.plugin.saveSettings();
})
);
}
}

0 comments on commit 020dbeb

Please sign in to comment.