From d51659d3d15060be7127b04d5e1ce8a09d45393f Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Sun, 17 Mar 2024 21:05:30 +0800 Subject: [PATCH] polish welcome screen --- docs/sync_algorithm/v3/intro.md | 2 +- src/langs/en.json | 7 ++++--- src/langs/zh_cn.json | 5 +++-- src/langs/zh_tw.json | 5 +++-- src/syncAlgoV3Notice.ts | 30 +++++++++++++++++++++++++++++- 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/docs/sync_algorithm/v3/intro.md b/docs/sync_algorithm/v3/intro.md index 0c1a16c..1faee0e 100644 --- a/docs/sync_algorithm/v3/intro.md +++ b/docs/sync_algorithm/v3/intro.md @@ -9,4 +9,4 @@ - [x] migration: old data auto transfer to new db (hopefully) - [ ] partial sync: force push - [ ] partial sync: force pull -- [ ] sync protection: warning based on the threshold +- [x] sync protection: warning based on the threshold diff --git a/src/langs/en.json b/src/langs/en.json index 8a18a8b..6d56df5 100644 --- a/src/langs/en.json +++ b/src/langs/en.json @@ -293,9 +293,10 @@ "settings_resetcache_desc": "Reset local internal caches/databases (for debugging purposes). You would want to reload the plugin after resetting this. This option will not empty the {s3, password...} settings.", "settings_resetcache_button": "Reset", "settings_resetcache_notice": "Local internal cache/databases deleted. Please manually reload the plugin.", - "syncalgov3_title": "Remotely Save has HUGE update on sync algorithm", - "syncalgov3_texts": "Welcome to use Remotely Save!\nFrom this version, a new algorithm has been developed: More robust deletion sync, basic conflict handling, no more meta data uploaded... Stay tune for more! A full introduction is in the doc website.\nIf you agree to use thew new version and algorithm, plase check \"I WILL BACKUP MY VAULT MANUALLY FIRSTLY.\" then click the \"Agree\" button, and enjoy the plugin!\nIf you do not agree, please click the \"Do Not Agree\" button, the plugin will unload itself, and you need to manually disable it in Obsidian settings.", - "syncalgov3_checkbox_manual_backup": "I WILL BACKUP MY VAULT MANUALLY FIRSTLY.", + "syncalgov3_title": "Remotely Save has a HUGE update on the sync algorithm", + "syncalgov3_texts": "Welcome to use Remotely Save!\nFrom this version, a new algorithm has been developed: More robust deletion sync, minimal conflict handling, no meta data uploaded any more, deletion / modification protection... Stay tune for more! A full introduction is in the doc website.\nIf you agree to use this, please read and check two checkboxes then click the \"Agree\" button, and enjoy the plugin!\nIf you do not agree, please click the \"Do Not Agree\" button, the plugin will unload itself.\nAlso, please consider visit the GitHub repo and star ⭐ it! Or even buy me a coffee. Your support is very important to me! Thanks!", + "syncalgov3_checkbox_manual_backup": "I will backup my vault manually firstly.", + "syncalgov3_checkbox_requiremultidevupdate": "I understand I need to update the plugin ACROSS ALL DEVICES to make them work properly.", "syncalgov3_button_agree": "Agree", "syncalgov3_button_disagree": "Do Not Agree" } diff --git a/src/langs/zh_cn.json b/src/langs/zh_cn.json index 62b1f8d..9474084 100644 --- a/src/langs/zh_cn.json +++ b/src/langs/zh_cn.json @@ -294,8 +294,9 @@ "settings_resetcache_button": "重设", "settings_resetcache_notice": "本地同步缓存和数据库已被删除。请手动重新载入此插件。", "syncalgov3_title": "Remotely Save 的同步算法有重大更新", - "syncalgov3_texts": "欢迎使用 Remotely Save!\n从这个版本开始,插件更新了同步算法:更稳健的删除同步、引入冲突处理、避免上传元数据…… 敬请期待更多更新!详细介绍请参阅 文档网站。\n如果您同意使用新版本和算法,请勾选“我将会手动备份我的库(Vault)”,然后点击“同意”按钮,开始使用插件吧!\n如果您不同意,请点击“不同意”按钮,插件将自动停止运行(unload),然后您需要 Obsidian 设置里手动停用(disable)此插件。", - "syncalgov3_checkbox_manual_backup": "我将会手动备份我的库(Vault)", + "syncalgov3_texts": "欢迎使用 Remotely Save!\n从这个版本开始,插件更新了同步算法:更稳健的删除同步、引入冲突处理、避免上传元数据、修改删除保护…… 敬请期待更多更新!详细介绍请参阅文档网站。\n如果您同意使用新版本,请阅读和勾选两个勾选框,然后点击“同意”按钮,开始使用插件吧!\n如果您不同意,请点击“不同意”按钮,插件将自动停止运行(unload)。\n此外,请考虑访问 GitHub 页面然后点赞 ⭐!您的支持对我十分重要!谢谢!", + "syncalgov3_checkbox_manual_backup": "我将会首先手动备份我的库(Vault)。", + "syncalgov3_checkbox_requiremultidevupdate": "我理解,我需要在所有设备上都更新此插件使之正常运行。", "syncalgov3_button_agree": "同意", "syncalgov3_button_disagree": "不同意" } diff --git a/src/langs/zh_tw.json b/src/langs/zh_tw.json index 57e6a72..003370a 100644 --- a/src/langs/zh_tw.json +++ b/src/langs/zh_tw.json @@ -294,8 +294,9 @@ "settings_resetcache_button": "重設", "settings_resetcache_notice": "本地同步快取和資料庫已被刪除。請手動重新載入此外掛。", "syncalgov3_title": "Remotely Save 的同步演算法有重大更新", - "syncalgov3_texts": "歡迎使用 Remotely Save!\n從這個版本開始,外掛更新了同步演算法:更穩健的刪除同步、引入衝突處理、避免上傳元資料…… 敬請期待更多更新!詳細介紹請參閱 文件網站。\n如果您同意使用新版本和演算法,請勾選“我將會手動備份我的庫(Vault)”,然後點選“同意”按鈕,開始使用外掛吧!\n如果您不同意,請點選“不同意”按鈕,外掛將自動停止執行(unload),然後您需要 Obsidian 設定裡手動停用(disable)此外掛。", - "syncalgov3_checkbox_manual_backup": "我將會手動備份我的庫(Vault)", + "syncalgov3_texts": "歡迎使用 Remotely Save!\n從這個版本開始,外掛更新了同步演算法:更穩健的刪除同步、引入衝突處理、避免上傳元資料、修改刪除保護…… 敬請期待更多更新!詳細介紹請參閱文件網站。\n如果您同意使用新版本,請閱讀和勾選兩個勾選框,然後點選“同意”按鈕,開始使用外掛吧!\n如果您不同意,請點選“不同意”按鈕,外掛將自動停止執行(unload)。\n此外,請考慮訪問 GitHub 頁面然後點贊 ⭐!您的支援對我十分重要!謝謝!", + "syncalgov3_checkbox_manual_backup": "我將會首先手動備份我的庫(Vault)。", + "syncalgov3_checkbox_requiremultidevupdate": "我理解,我需要在所有裝置上都更新此外掛使之正常執行。", "syncalgov3_button_agree": "同意", "syncalgov3_button_disagree": "不同意" } diff --git a/src/syncAlgoV3Notice.ts b/src/syncAlgoV3Notice.ts index a12ec10..22e820b 100644 --- a/src/syncAlgoV3Notice.ts +++ b/src/syncAlgoV3Notice.ts @@ -7,12 +7,14 @@ import { stringToFragment } from "./misc"; export class SyncAlgoV3Modal extends Modal { agree: boolean; manualBackup: boolean; + requireUpdateAllDev: boolean; readonly plugin: RemotelySavePlugin; constructor(app: App, plugin: RemotelySavePlugin) { super(app); this.plugin = plugin; this.agree = false; this.manualBackup = false; + this.requireUpdateAllDev = false; } onOpen() { let { contentEl } = this; @@ -36,6 +38,7 @@ export class SyncAlgoV3Modal extends Modal { // code modified partially from BART released under MIT License contentEl.createDiv("modal-button-container", (buttonContainerEl) => { let agreeBtn: HTMLButtonElement | undefined = undefined; + buttonContainerEl.createEl( "label", { @@ -50,7 +53,7 @@ export class SyncAlgoV3Modal extends Modal { checkboxEl.addEventListener("click", () => { this.manualBackup = checkboxEl.checked; if (agreeBtn !== undefined) { - if (checkboxEl.checked) { + if (this.manualBackup && this.requireUpdateAllDev) { agreeBtn.removeAttribute("disabled"); } else { agreeBtn.setAttr("disabled", true); @@ -61,6 +64,31 @@ export class SyncAlgoV3Modal extends Modal { } ); + buttonContainerEl.createEl( + "label", + { + cls: "mod-checkbox", + }, + (labelEl) => { + const checkboxEl = labelEl.createEl("input", { + attr: { tabindex: -1 }, + type: "checkbox", + }); + checkboxEl.checked = this.requireUpdateAllDev; + checkboxEl.addEventListener("click", () => { + this.requireUpdateAllDev = checkboxEl.checked; + if (agreeBtn !== undefined) { + if (this.manualBackup && this.requireUpdateAllDev) { + agreeBtn.removeAttribute("disabled"); + } else { + agreeBtn.setAttr("disabled", true); + } + } + }); + labelEl.appendText(t("syncalgov3_checkbox_requiremultidevupdate")); + } + ); + agreeBtn = buttonContainerEl.createEl("button", { attr: { type: "button" }, cls: "mod-cta",