add preset rules for webdav

This commit is contained in:
fyears
2022-04-04 23:53:36 +08:00
parent 429063ebd1
commit 41073d1576
4 changed files with 200 additions and 0 deletions
+9
View File
@@ -51,6 +51,7 @@ import type { LangType, LangTypeAndAuto, TransItemType } from "./i18n";
import * as origLog from "loglevel";
import { DeletionOnRemote, MetadataOnRemote } from "./metadataOnRemote";
import { SyncAlgoV2Modal } from "./syncAlgoV2Notice";
import { applyPresetRulesInplace } from "./presetRules";
const log = origLog.getLogger("rs-default");
const DEFAULT_SETTINGS: RemotelySavePluginSettings = {
@@ -373,6 +374,7 @@ export default class RemotelySavePlugin extends Plugin {
this.currSyncMsg = "";
await this.loadSettings();
await this.checkIfPresetRulesFollowed();
// lang should be load early, but after settings
this.i18n = new I18n(this.settings.lang, async (lang: LangTypeAndAuto) => {
@@ -706,6 +708,13 @@ export default class RemotelySavePlugin extends Plugin {
}
}
async checkIfPresetRulesFollowed() {
const res = applyPresetRulesInplace(this.settings);
if (res.changed) {
await this.saveSettings();
}
}
async saveSettings() {
await this.saveData(normalConfigToMessy(this.settings));
}