mirror of
https://github.com/koodo-reader/koodo-reader.git
synced 2025-12-23 23:17:55 -05:00
Refactor drive and login list handling to remove isCNAvailable checks
- Updated BackupDialog and ImportDialog components to directly use driveList without filtering based on isCNAvailable. - Removed isCNAvailable property from driveList and loginList constants. - Simplified login option selection in AccountSetting and Login components by eliminating region-based filtering. - Adjusted SyncSetting component to utilize the full driveList without CN availability checks. - Updated yarn.lock to reflect changes in megajs dependency version.
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
"localforage": "^1.10.0",
|
||||
"mammoth": "^1.8.0",
|
||||
"marked": "^15.0.11",
|
||||
"megajs": "1.3.9-next.17",
|
||||
"megajs": "^1.3.9",
|
||||
"mhtml2html": "^3.0.0",
|
||||
"node-machine-id": "^1.1.12",
|
||||
"qs": "^6.11.2",
|
||||
|
||||
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
@@ -156,12 +156,7 @@ class BackupDialog extends React.Component<
|
||||
>
|
||||
{[
|
||||
{ label: "Local", value: "local", isPro: false },
|
||||
...driveList.filter((item) => {
|
||||
if (getServerRegion() === "china") {
|
||||
return item.isCNAvailable;
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
...driveList,
|
||||
{ label: "Add data source", value: "add", isPro: false },
|
||||
]
|
||||
.filter(
|
||||
@@ -210,12 +205,7 @@ class BackupDialog extends React.Component<
|
||||
>
|
||||
{[
|
||||
{ label: "Local", value: "local", isPro: false },
|
||||
...driveList.filter((item) => {
|
||||
if (getServerRegion() === "china") {
|
||||
return item.isCNAvailable;
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
...driveList,
|
||||
{ label: "Add data source", value: "add", isPro: false },
|
||||
]
|
||||
.filter(
|
||||
|
||||
@@ -368,12 +368,6 @@ class ImportDialog extends React.Component<
|
||||
{this.state.currentDrive === "" && (
|
||||
<>
|
||||
{driveList
|
||||
.filter((item) => {
|
||||
if (getServerRegion() === "china") {
|
||||
return item.isCNAvailable;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.filter(
|
||||
(item) =>
|
||||
!item.scoped &&
|
||||
|
||||
@@ -6,7 +6,6 @@ export const driveList = [
|
||||
isPro: false,
|
||||
support: ["desktop", "browser", "phone"],
|
||||
scoped: false,
|
||||
isCNAvailable: true,
|
||||
},
|
||||
{
|
||||
label: "S3 Compatible",
|
||||
@@ -15,7 +14,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "browser", "phone"],
|
||||
scoped: false,
|
||||
isCNAvailable: true,
|
||||
},
|
||||
{
|
||||
label: "Docker",
|
||||
@@ -24,7 +22,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "browser", "phone"],
|
||||
scoped: true,
|
||||
isCNAvailable: true,
|
||||
},
|
||||
{
|
||||
label: "OneDrive",
|
||||
@@ -33,7 +30,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "browser", "phone"],
|
||||
scoped: true,
|
||||
isCNAvailable: true,
|
||||
},
|
||||
{
|
||||
label: "Google Drive",
|
||||
@@ -42,7 +38,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "browser", "phone"],
|
||||
scoped: false,
|
||||
isCNAvailable: false,
|
||||
},
|
||||
{
|
||||
label: "Dropbox",
|
||||
@@ -51,7 +46,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "browser", "phone"],
|
||||
scoped: true,
|
||||
isCNAvailable: false,
|
||||
},
|
||||
|
||||
{
|
||||
@@ -61,7 +55,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "phone"],
|
||||
scoped: false,
|
||||
isCNAvailable: true,
|
||||
},
|
||||
|
||||
{
|
||||
@@ -71,7 +64,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "browser", "phone"],
|
||||
scoped: false,
|
||||
isCNAvailable: false,
|
||||
},
|
||||
|
||||
{
|
||||
@@ -81,7 +73,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "browser"],
|
||||
scoped: false,
|
||||
isCNAvailable: false,
|
||||
},
|
||||
{
|
||||
label: "Aliyun Drive",
|
||||
@@ -90,7 +81,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "phone"],
|
||||
scoped: false,
|
||||
isCNAvailable: true,
|
||||
},
|
||||
{
|
||||
label: "Yandex Disk",
|
||||
@@ -99,7 +89,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "phone"],
|
||||
scoped: false,
|
||||
isCNAvailable: false,
|
||||
},
|
||||
{
|
||||
label: "115 Yun",
|
||||
@@ -108,7 +97,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "phone"],
|
||||
scoped: false,
|
||||
isCNAvailable: true,
|
||||
},
|
||||
|
||||
{
|
||||
@@ -118,7 +106,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "phone"],
|
||||
scoped: true,
|
||||
isCNAvailable: false,
|
||||
},
|
||||
|
||||
{
|
||||
@@ -128,7 +115,6 @@ export const driveList = [
|
||||
isPro: true,
|
||||
support: ["desktop", "browser", "phone"],
|
||||
scoped: false,
|
||||
isCNAvailable: true,
|
||||
},
|
||||
|
||||
{
|
||||
@@ -138,7 +124,6 @@ export const driveList = [
|
||||
isPro: false,
|
||||
support: ["desktop"],
|
||||
scoped: false,
|
||||
isCNAvailable: true,
|
||||
},
|
||||
{
|
||||
label: "SFTP",
|
||||
@@ -147,7 +132,6 @@ export const driveList = [
|
||||
isPro: false,
|
||||
support: ["desktop"],
|
||||
scoped: false,
|
||||
isCNAvailable: true,
|
||||
},
|
||||
];
|
||||
interface ConfigItem {
|
||||
|
||||
@@ -4,27 +4,23 @@ export const loginList = [
|
||||
value: "github",
|
||||
icon: "icon-github",
|
||||
fontsize: "20px",
|
||||
isCNAvailable: false,
|
||||
},
|
||||
{
|
||||
label: "Google",
|
||||
value: "google",
|
||||
icon: "icon-google",
|
||||
fontsize: "17px",
|
||||
isCNAvailable: false,
|
||||
},
|
||||
{
|
||||
label: "Email",
|
||||
value: "email",
|
||||
icon: "icon-email",
|
||||
fontsize: "20px",
|
||||
isCNAvailable: true,
|
||||
},
|
||||
{
|
||||
label: "Microsoft",
|
||||
value: "microsoft",
|
||||
icon: "icon-microsoft",
|
||||
fontsize: "17px",
|
||||
isCNAvailable: true,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -622,109 +622,96 @@ class AccountSetting extends React.Component<
|
||||
className="lang-setting-dropdown"
|
||||
onChange={this.handleAddLoginOption}
|
||||
>
|
||||
{[
|
||||
{ label: "Please select", value: "" },
|
||||
...loginList.filter((item) => {
|
||||
if (getServerRegion() === "china") {
|
||||
return item.isCNAvailable;
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
].map((item) => (
|
||||
<option
|
||||
value={item.value}
|
||||
key={item.value}
|
||||
className="lang-setting-option"
|
||||
>
|
||||
{this.props.t(item.label)}
|
||||
</option>
|
||||
))}
|
||||
{[{ label: "Please select", value: "" }, ...loginList].map(
|
||||
(item) => (
|
||||
<option
|
||||
value={item.value}
|
||||
key={item.value}
|
||||
className="lang-setting-option"
|
||||
>
|
||||
{this.props.t(item.label)}
|
||||
</option>
|
||||
)
|
||||
)}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
{this.props.isAuthed &&
|
||||
loginList
|
||||
.filter((item) => {
|
||||
if (this.state.serverRegion === "china") {
|
||||
return item.isCNAvailable;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.map((login) => (
|
||||
<div className="setting-dialog-new-title" key={login.value}>
|
||||
<Trans>{this.props.t(login.label)}</Trans>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
onClick={() => {
|
||||
if (
|
||||
!this.props.loginOptionList.find(
|
||||
(item) => item.provider === login.value
|
||||
)
|
||||
) {
|
||||
this.handleAddLoginOption({
|
||||
target: { value: login.value },
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
{this.props.loginOptionList.find(
|
||||
loginList.map((login) => (
|
||||
<div className="setting-dialog-new-title" key={login.value}>
|
||||
<Trans>{this.props.t(login.label)}</Trans>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
onClick={() => {
|
||||
if (
|
||||
!this.props.loginOptionList.find(
|
||||
(item) => item.provider === login.value
|
||||
) ? (
|
||||
this.props.loginOptionList.find(
|
||||
(item) => item.provider === login.value
|
||||
)?.email ? (
|
||||
<span>
|
||||
{
|
||||
this.props.loginOptionList.find(
|
||||
(item) => item.provider === login.value
|
||||
)?.email
|
||||
}
|
||||
</span>
|
||||
) : (
|
||||
<span>{this.props.t("Bound")}</span>
|
||||
)
|
||||
) : (
|
||||
<span style={{ opacity: 0.4 }}>
|
||||
{this.props.t("Not bound")}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
) {
|
||||
this.handleAddLoginOption({
|
||||
target: { value: login.value },
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
{this.props.loginOptionList.find(
|
||||
(item) => item.provider === login.value
|
||||
) ? (
|
||||
<span
|
||||
className="icon-trash"
|
||||
style={{
|
||||
fontSize: 13,
|
||||
opacity: 0.8,
|
||||
marginLeft: "10px",
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
this.handleDeleteLoginOption({
|
||||
target: { value: login.value },
|
||||
});
|
||||
}}
|
||||
></span>
|
||||
this.props.loginOptionList.find(
|
||||
(item) => item.provider === login.value
|
||||
)?.email ? (
|
||||
<span>
|
||||
{
|
||||
this.props.loginOptionList.find(
|
||||
(item) => item.provider === login.value
|
||||
)?.email
|
||||
}
|
||||
</span>
|
||||
) : (
|
||||
<span>{this.props.t("Bound")}</span>
|
||||
)
|
||||
) : (
|
||||
<span
|
||||
className="icon-dropdown"
|
||||
style={{
|
||||
fontSize: 13,
|
||||
opacity: 0.8,
|
||||
transform: "rotate(-90deg)",
|
||||
marginLeft: "10px",
|
||||
}}
|
||||
></span>
|
||||
<span style={{ opacity: 0.4 }}>
|
||||
{this.props.t("Not bound")}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{this.props.loginOptionList.find(
|
||||
(item) => item.provider === login.value
|
||||
) ? (
|
||||
<span
|
||||
className="icon-trash"
|
||||
style={{
|
||||
fontSize: 13,
|
||||
opacity: 0.8,
|
||||
marginLeft: "10px",
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
this.handleDeleteLoginOption({
|
||||
target: { value: login.value },
|
||||
});
|
||||
}}
|
||||
></span>
|
||||
) : (
|
||||
<span
|
||||
className="icon-dropdown"
|
||||
style={{
|
||||
fontSize: 13,
|
||||
opacity: 0.8,
|
||||
transform: "rotate(-90deg)",
|
||||
marginLeft: "10px",
|
||||
}}
|
||||
></span>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
|
||||
{this.props.isAuthed && (
|
||||
<div className="setting-dialog-new-title">
|
||||
|
||||
@@ -586,12 +586,7 @@ class SyncSetting extends React.Component<SettingInfoProps, SettingInfoState> {
|
||||
isPro: false,
|
||||
support: ["desktop", "browser", "phone"],
|
||||
},
|
||||
...driveList.filter((item) => {
|
||||
if (getServerRegion() === "china") {
|
||||
return item.isCNAvailable;
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
...driveList,
|
||||
]
|
||||
.filter((item) => !this.props.dataSourceList.includes(item.value))
|
||||
.filter((item) => {
|
||||
@@ -622,15 +617,7 @@ class SyncSetting extends React.Component<SettingInfoProps, SettingInfoState> {
|
||||
className="lang-setting-dropdown"
|
||||
onChange={this.handleDeleteDataSource}
|
||||
>
|
||||
{[
|
||||
{ label: "Please select", value: "", isPro: false },
|
||||
...driveList.filter((item) => {
|
||||
if (getServerRegion() === "china") {
|
||||
return item.isCNAvailable;
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
]
|
||||
{[{ label: "Please select", value: "", isPro: false }, ...driveList]
|
||||
.filter(
|
||||
(item) =>
|
||||
this.props.dataSourceList.includes(item.value) ||
|
||||
@@ -688,12 +675,7 @@ class SyncSetting extends React.Component<SettingInfoProps, SettingInfoState> {
|
||||
>
|
||||
{[
|
||||
{ label: "Please select", value: "", isPro: false },
|
||||
...driveList.filter((item) => {
|
||||
if (getServerRegion() === "china") {
|
||||
return item.isCNAvailable;
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
...driveList,
|
||||
]
|
||||
.filter(
|
||||
(item) =>
|
||||
|
||||
@@ -346,56 +346,48 @@ class Login extends React.Component<LoginProps, LoginState> {
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{loginList
|
||||
.filter((item) => {
|
||||
if (this.state.serverRegion === "china") {
|
||||
return item.isCNAvailable;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.map((item) => {
|
||||
return (
|
||||
<div
|
||||
className="login-option-container"
|
||||
key={item.value}
|
||||
style={{}}
|
||||
onClick={() => {
|
||||
if (item.value === "email") {
|
||||
this.setState({ currentStep: 5 });
|
||||
return;
|
||||
{loginList.map((item) => {
|
||||
return (
|
||||
<div
|
||||
className="login-option-container"
|
||||
key={item.value}
|
||||
style={{}}
|
||||
onClick={() => {
|
||||
if (item.value === "email") {
|
||||
this.setState({ currentStep: 5 });
|
||||
return;
|
||||
}
|
||||
let url = LoginHelper.getAuthUrl(
|
||||
item.value,
|
||||
isElectron ? "desktop" : "browser",
|
||||
getServerRegion() === "china" &&
|
||||
item.value === "microsoft"
|
||||
? KookitConfig.ThirdpartyConfig.cnCallbackUrl
|
||||
: KookitConfig.ThirdpartyConfig.callbackUrl
|
||||
);
|
||||
if (url) {
|
||||
if (isElectron) {
|
||||
openInBrowser(url);
|
||||
} else {
|
||||
window.location.replace(url);
|
||||
}
|
||||
let url = LoginHelper.getAuthUrl(
|
||||
item.value,
|
||||
isElectron ? "desktop" : "browser",
|
||||
getServerRegion() === "china" &&
|
||||
item.value === "microsoft"
|
||||
? KookitConfig.ThirdpartyConfig.cnCallbackUrl
|
||||
: KookitConfig.ThirdpartyConfig.callbackUrl
|
||||
);
|
||||
if (url) {
|
||||
if (isElectron) {
|
||||
openInBrowser(url);
|
||||
} else {
|
||||
window.location.replace(url);
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="login-option-icon">
|
||||
<span
|
||||
className={item.icon + " login-option-icon"}
|
||||
style={{ fontSize: item.fontsize }}
|
||||
></span>
|
||||
</div>
|
||||
<div className="login-option-title">
|
||||
<Trans i18nKey="Continue with" label={item.label}>
|
||||
Continue with{" "}
|
||||
{{ label: this.props.t(item.label) }}
|
||||
</Trans>
|
||||
</div>
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="login-option-icon">
|
||||
<span
|
||||
className={item.icon + " login-option-icon"}
|
||||
style={{ fontSize: item.fontsize }}
|
||||
></span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<div className="login-option-title">
|
||||
<Trans i18nKey="Continue with" label={item.label}>
|
||||
Continue with {{ label: this.props.t(item.label) }}
|
||||
</Trans>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<div
|
||||
className="login-manual-token"
|
||||
onClick={() => {
|
||||
@@ -453,12 +445,6 @@ class Login extends React.Component<LoginProps, LoginState> {
|
||||
</div>
|
||||
<div className="login-sync-container">
|
||||
{driveList
|
||||
.filter((item) => {
|
||||
if (getServerRegion() === "china") {
|
||||
return item.isCNAvailable;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.filter((item) => {
|
||||
if (!isElectron) {
|
||||
return item.support.includes("browser");
|
||||
|
||||
@@ -10588,10 +10588,10 @@ media-typer@0.3.0:
|
||||
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
|
||||
integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==
|
||||
|
||||
megajs@1.3.9-next.17:
|
||||
version "1.3.9-next.17"
|
||||
resolved "https://registry.yarnpkg.com/megajs/-/megajs-1.3.9-next.17.tgz#7e8d65977b57c9b514e60e7a24a04923d8d8a96a"
|
||||
integrity sha512-wfGcxOWgO25E/7BP7GbVz6EDKHES/4Q87kdHs9aCzne1veRVRJh1LsKZBczZ35N0zu0Xd0+vNCDdwNGK9QJPVw==
|
||||
megajs@^1.3.9:
|
||||
version "1.3.9"
|
||||
resolved "https://registry.yarnpkg.com/megajs/-/megajs-1.3.9.tgz#2a495ffc1264ae333206f4f5bf70a401d48e55bf"
|
||||
integrity sha512-91GGJbUfUu9z/KFORHcn4bugVILWcGahaoy07Q7M5GLzT6zOsrpusxkjEvEys9XCXbxntg0v+f2JN6sITrEkPQ==
|
||||
dependencies:
|
||||
pumpify "^2.0.1"
|
||||
stream-skip "^1.0.3"
|
||||
|
||||
Reference in New Issue
Block a user