FFLOW 0.3.0: everything is a flow; steps set any properties, symbol and hotkeys share them
This commit is contained in:
1 parent
68e390fb37
commit
8553b7c75a
12 files changed
+423
-335
No files matched your search
+5
-11
@@ -1,6 +1,6 @@
|
||||
import { Plugin } from "obsidian";
|
||||
import { FlowCommands } from "./flows";
|
||||
import { DEFAULT_SETTINGS, FflowSettings, NEW_RULE } from "./settings";
|
||||
import { FflowSettings, loadSettings } from "./settings";
|
||||
import { FflowSettingTab } from "./settings-tab";
|
||||
import { TriggerSuggest, ValueIndex } from "./suggest";
|
||||
|
||||
@@ -9,7 +9,10 @@ export default class FflowPlugin extends Plugin {
|
||||
private flowCommands = new FlowCommands(this);
|
||||
|
||||
async onload(): Promise<void> {
|
||||
await this.loadSettings();
|
||||
const saved: unknown = await this.loadData();
|
||||
this.settings = loadSettings(saved);
|
||||
// Persist a migration from the old trigger/flow format right away.
|
||||
if (saved && typeof saved === "object" && "rules" in saved) await this.saveData(this.settings);
|
||||
|
||||
const index = new ValueIndex(this.app);
|
||||
this.registerEvent(this.app.metadataCache.on("changed", () => index.invalidate()));
|
||||
@@ -20,15 +23,6 @@ export default class FflowPlugin extends Plugin {
|
||||
this.addSettingTab(new FflowSettingTab(this.app, this));
|
||||
}
|
||||
|
||||
async loadSettings(): Promise<void> {
|
||||
const saved = ((await this.loadData()) ?? {}) as Partial<FflowSettings>;
|
||||
this.settings = {
|
||||
// Fill fields added after a rule was saved (e.g. flowId in 0.2.0).
|
||||
rules: (saved.rules ?? DEFAULT_SETTINGS.rules).map((r) => ({ ...NEW_RULE, ...r })),
|
||||
flows: saved.flows ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
async saveSettings(): Promise<void> {
|
||||
await this.saveData(this.settings);
|
||||
this.flowCommands.sync();
|
||||
|
||||
Reference in new issue
Block a user