mirror of
https://github.com/koodo-reader/koodo-reader.git
synced 2025-12-23 23:17:55 -05:00
feat: add Koodo Sync reset functionality and update translations
- Added a new translation for the scenario where a data source already contains a library. - Implemented resetKoodoSync function to handle enabling and disabling Koodo Sync. - Updated the header component to utilize the resetKoodoSync function. - Modified sync settings component to call resetKoodoSync when changing sync options and added a toast notification for existing cloud data. - Introduced isCloudEmpty method in ConfigUtil to check if the cloud data is empty before merging.
This commit is contained in:
2
src/assets/lib/kookit-extra-browser.min.js
vendored
2
src/assets/lib/kookit-extra-browser.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -209,6 +209,7 @@
|
||||
"Page width": "页面宽度",
|
||||
"Tasks failed after multiple retries, please check the network connection": "多次重试后任务失败,请检查网络连接",
|
||||
"Tasks failed after multiple retries, please check the network connection or reauthorize the data source in the settings": "多次重试后任务失败,请检查网络连接或在设置中重新授权数据源",
|
||||
"This data source already contains a library. If you need to merge local and cloud data, please turn off Koodo Sync and resync.": "此数据源已经存在了一个图书库,如果需要将本地和云端的数据合并。请关闭 Koodo Sync 后重新同步。",
|
||||
"Render PDF from even page": "从偶数页开始渲染 PDF",
|
||||
"Filter by book": "按图书筛选",
|
||||
"Server path (Please first create this folder manually)": "服务器路径(请先手动创建此文件夹)",
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
getChatLocale,
|
||||
getWebsiteUrl,
|
||||
removeChatBox,
|
||||
resetKoodoSync,
|
||||
showTaskProgress,
|
||||
} from "../../utils/common";
|
||||
import { driveList } from "../../constants/driveList";
|
||||
@@ -295,16 +296,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
|
||||
this.props.handleFetchDefaultSyncOption();
|
||||
}
|
||||
if (ConfigService.getReaderConfig("isEnableKoodoSync") === "yes") {
|
||||
await updateUserConfig({
|
||||
is_enable_koodo_sync: "no",
|
||||
default_sync_option:
|
||||
ConfigService.getItem("defaultSyncOption") === "google",
|
||||
});
|
||||
setTimeout(() => {
|
||||
updateUserConfig({
|
||||
is_enable_koodo_sync: "yes",
|
||||
});
|
||||
}, 1000);
|
||||
await resetKoodoSync();
|
||||
}
|
||||
toast(
|
||||
this.props.t(
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
handleContextMenu,
|
||||
openExternalUrl,
|
||||
openInBrowser,
|
||||
resetKoodoSync,
|
||||
showTaskProgress,
|
||||
testConnection,
|
||||
testCORS,
|
||||
@@ -36,6 +37,7 @@ import SyncService from "../../../utils/storage/syncService";
|
||||
import { updateUserConfig } from "../../../utils/request/user";
|
||||
import BookUtil from "../../../utils/file/bookUtil";
|
||||
import Book from "../../../models/Book";
|
||||
import ConfigUtil from "../../../utils/file/configUtil";
|
||||
declare var window: any;
|
||||
class SyncSetting extends React.Component<SettingInfoProps, SettingInfoState> {
|
||||
constructor(props: SettingInfoProps) {
|
||||
@@ -151,12 +153,23 @@ class SyncSetting extends React.Component<SettingInfoProps, SettingInfoState> {
|
||||
}
|
||||
ConfigService.setItem("defaultSyncOption", event.target.value);
|
||||
if (ConfigService.getReaderConfig("isEnableKoodoSync") === "yes") {
|
||||
updateUserConfig({
|
||||
default_sync_option: event.target.value,
|
||||
});
|
||||
await resetKoodoSync();
|
||||
}
|
||||
this.props.handleFetchDefaultSyncOption();
|
||||
toast.success(this.props.t("Change successful"));
|
||||
if (
|
||||
!(await ConfigUtil.isCloudEmpty()) &&
|
||||
ConfigService.getReaderConfig("isEnableKoodoSync") === "yes"
|
||||
) {
|
||||
toast(
|
||||
this.props.t(
|
||||
"This data source already contains a library. If you need to merge local and cloud data, please turn off Koodo Sync and resync."
|
||||
),
|
||||
{
|
||||
duration: 10000,
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
handleCancelDrive = () => {
|
||||
this.props.handleSettingDrive("");
|
||||
|
||||
@@ -19,6 +19,7 @@ import { getCloudConfig } from "./file/common";
|
||||
import SyncService from "./storage/syncService";
|
||||
import localforage from "localforage";
|
||||
import { driveList } from "../constants/driveList";
|
||||
import { updateUserConfig } from "./request/user";
|
||||
declare var window: any;
|
||||
export const supportedFormats = [
|
||||
".epub",
|
||||
@@ -944,3 +945,15 @@ export const clearAllData = async () => {
|
||||
}
|
||||
await localforage.clear();
|
||||
};
|
||||
export const resetKoodoSync = async () => {
|
||||
await updateUserConfig({
|
||||
is_enable_koodo_sync: "no",
|
||||
default_sync_option: ConfigService.getItem("defaultSyncOption"),
|
||||
});
|
||||
setTimeout(() => {
|
||||
updateUserConfig({
|
||||
is_enable_koodo_sync: "yes",
|
||||
default_sync_option: ConfigService.getItem("defaultSyncOption"),
|
||||
});
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
@@ -281,5 +281,14 @@ class ConfigUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
static async isCloudEmpty() {
|
||||
let syncDataStr = await this.downloadConfig("sync");
|
||||
let syncData = JSON.parse(syncDataStr || "{}");
|
||||
console.log(syncData, "syncdata");
|
||||
if (!syncData || Object.keys(syncData).length === 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
export default ConfigUtil;
|
||||
|
||||
Reference in New Issue
Block a user