From 99926adbbd923df846fadc8793fe800054d2fde9 Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Wed, 23 Mar 2022 22:54:44 +0800 Subject: [PATCH] more hints for webdav --- src/langs | 2 +- src/remoteForWebdav.ts | 11 +++++++++-- src/settings.ts | 35 ++++++++++++++++++++--------------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/langs b/src/langs index 2873058..475d524 160000 --- a/src/langs +++ b/src/langs @@ -1 +1 @@ -Subproject commit 28730585f8cef9625b2b5a2296318c1c071ff7ba +Subproject commit 475d524994493a53bfffabbad6bfa25259197a2d diff --git a/src/remoteForWebdav.ts b/src/remoteForWebdav.ts index 6f0ee3b..20da7ff 100644 --- a/src/remoteForWebdav.ts +++ b/src/remoteForWebdav.ts @@ -1,5 +1,11 @@ import { Buffer } from "buffer"; -import { Vault, request, requestUrl, requireApiVersion } from "obsidian"; +import { + Vault, + request, + requestUrl, + requireApiVersion, + Platform, +} from "obsidian"; import { Queue } from "@fyears/tsqueue"; import chunk from "lodash/chunk"; @@ -20,7 +26,7 @@ import type { ResponseDataDetailed, } from "webdav/web"; import { getPatcher } from "webdav/web"; -if (requireApiVersion(API_VER_REQURL)) { +if (requireApiVersion(API_VER_REQURL) && !Platform.isAndroidApp) { getPatcher().patch( "request", async ( @@ -110,6 +116,7 @@ if (requireApiVersion(API_VER_REQURL)) { // return r; // }); import { AuthType, BufferLike, createClient } from "webdav/web"; +import { Plane } from "lucide"; export type { WebDAVClient } from "webdav/web"; export const DEFAULT_WEBDAV_CONFIG = { diff --git a/src/settings.ts b/src/settings.ts index 8aa1011..5728caf 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1105,6 +1105,9 @@ export class RemotelySaveSettingTab extends PluginSettingTab { this.plugin.settings.serviceType !== "webdav" ); + const webdavReq = + requireApiVersion(API_VER_REQURL) && !Platform.isAndroidApp; + webdavDiv.createEl("h2", { text: t("settings_webdav") }); webdavDiv.createEl("p", { @@ -1112,7 +1115,17 @@ export class RemotelySaveSettingTab extends PluginSettingTab { cls: "webdav-disclaimer", }); - if (!requireApiVersion(API_VER_REQURL)) { + if (!webdavReq) { + if (Platform.isAndroidApp) { + webdavDiv.createEl("p", { + text: t("settings_webdav_cors_android"), + }); + } else { + webdavDiv.createEl("p", { + text: t("settings_webdav_cors_otheros"), + }); + } + webdavDiv.createEl("p", { text: t("settings_webdav_cors"), }); @@ -1168,15 +1181,12 @@ export class RemotelySaveSettingTab extends PluginSettingTab { .setDesc(t("settings_webdav_auth_desc")) .addDropdown(async (dropdown) => { dropdown.addOption("basic", "basic"); - if (requireApiVersion(API_VER_REQURL)) { + if (webdavReq) { dropdown.addOption("digest", "digest"); } // new version config, copied to old version, we need to reset it - if ( - !requireApiVersion(API_VER_REQURL) && - this.plugin.settings.webdav.authType !== "basic" - ) { + if (!webdavReq && this.plugin.settings.webdav.authType !== "basic") { this.plugin.settings.webdav.authType = "basic"; await this.plugin.saveSettings(); } @@ -1249,16 +1259,11 @@ export class RemotelySaveSettingTab extends PluginSettingTab { if (res) { new Notice(t("settings_webdav_connect_succ")); } else { - let corsErrMsg = "/CORS"; - if (requireApiVersion(API_VER_REQURL)) { - corsErrMsg = ""; + if (webdavReq) { + new Notice(t("settings_webdav_connect_fail")); + } else { + new Notice(t("settings_webdav_connect_fail_withcors")); } - - new Notice( - t("settings_webdav_connect_fail", { - corsErrMsg: corsErrMsg, - }) - ); new Notice(errors.msg); } });