From 8ba78d2de4b38ae7fe5a93c67d87fe148da790f2 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Wed, 10 Sep 2025 01:45:41 -0400 Subject: [PATCH] CloudTab: Add Default Buttons --- .github/ISSUE_TEMPLATE/blank.yml | 4 +- .../settings/tabs/sync/CloudTab.tsx | 42 ++++++++++++++----- src/utils/cloud.tsx | 29 +------------ src/utils/settingsSync.ts | 8 +--- 4 files changed, 35 insertions(+), 48 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/blank.yml b/.github/ISSUE_TEMPLATE/blank.yml index 89588f3d8..8deb782ca 100644 --- a/.github/ISSUE_TEMPLATE/blank.yml +++ b/.github/ISSUE_TEMPLATE/blank.yml @@ -5,9 +5,9 @@ body: - type: markdown attributes: value: | - ![Are you a developer? No? This form is not for you!](https://github.com/Vendicated/Vencord/blob/main/.github/ISSUE_TEMPLATE/developer-banner.png?raw=true) + ![Are you a developer? No? This form is not for you!](https://github.com/Equicord/Equicord/blob/main/.github/ISSUE_TEMPLATE/developer-banner.png?raw=true) - GitHub Issues are for development, not support! Please use our [support server](https://vencord.dev/discord) unless you are a Vencord Developer. + GitHub Issues are for development, not support! Please use our [support server](https://equicord.org/discord) unless you are a Vencord Developer. - type: textarea id: content diff --git a/src/components/settings/tabs/sync/CloudTab.tsx b/src/components/settings/tabs/sync/CloudTab.tsx index 07489cb62..7f8295ff8 100644 --- a/src/components/settings/tabs/sync/CloudTab.tsx +++ b/src/components/settings/tabs/sync/CloudTab.tsx @@ -22,10 +22,10 @@ import { CheckedTextInput } from "@components/CheckedTextInput"; import { Grid } from "@components/Grid"; import { Link } from "@components/Link"; import { SettingsTab, wrapTab } from "@components/settings/tabs/BaseTab"; -import { authorizeCloud, checkCloudUrlCsp, cloudLogger, deauthorizeCloud, getCloudAuth, getCloudUrl } from "@utils/cloud"; +import { authorizeCloud, cloudLogger, deauthorizeCloud, getCloudAuth, getCloudUrl } from "@utils/cloud"; import { Margins } from "@utils/margins"; import { deleteCloudSettings, getCloudSettings, putCloudSettings } from "@utils/settingsSync"; -import { Alerts, Button, Forms, Switch, Tooltip } from "@webpack/common"; +import { Alerts, Button, Forms, Switch, Tooltip, useState } from "@webpack/common"; function validateUrl(url: string) { try { @@ -37,8 +37,6 @@ function validateUrl(url: string) { } async function eraseAllData() { - if (!await checkCloudUrlCsp()) return; - const res = await fetch(new URL("/v1/", getCloudUrl()), { method: "DELETE", headers: { Authorization: await getCloudAuth() } @@ -119,15 +117,31 @@ function SettingsSyncSection() { function CloudTab() { const settings = useSettings(["cloud.authenticated", "cloud.url"]); + const [inputKey, setInputKey] = useState(0); + + async function changeUrl(url: string) { + settings.cloud.url = url; + settings.cloud.authenticated = false; + + await deauthorizeCloud(); + await authorizeCloud(); + + setInputKey(prev => prev + 1); + } return ( - Equicord comes with a cloud integration that adds goodies like settings sync across devices. - It respects your privacy, and - the source code is AGPL 3.0 licensed so you - can host it yourself. + Equicord comes with a cloud integration allowing settings to be synced across apps and devices. +
+ We use Vencord's cloud source code to provide our cloud instance which has a 32MB backup cap. +
+ Our privacy policy allows you to see what information we store, how we use it, and data retention. +
+ The Vencord Cloud repository is AGPL 3.0 licensed so you can host it yourself it you would like. +
+ You can swap between Equicord and Vencord's different cloud instances below if needed.
{ settings.cloud.url = v; settings.cloud.authenticated = false; - deauthorizeCloud(); + await deauthorizeCloud(); }} validate={validateUrl} /> @@ -162,8 +176,8 @@ function CloudTab() { size={Button.Sizes.MEDIUM} disabled={!settings.cloud.authenticated} onClick={async () => { - await deauthorizeCloud(); settings.cloud.authenticated = false; + await deauthorizeCloud(); await authorizeCloud(); }} > @@ -184,6 +198,12 @@ function CloudTab() { > Erase All Data + + diff --git a/src/utils/cloud.tsx b/src/utils/cloud.tsx index 6e0c49f7f..8895e419b 100644 --- a/src/utils/cloud.tsx +++ b/src/utils/cloud.tsx @@ -19,41 +19,16 @@ import * as DataStore from "@api/DataStore"; import { showNotification } from "@api/Notifications"; import { Settings } from "@api/Settings"; -import { Alerts, OAuth2AuthorizeModal, UserStore } from "@webpack/common"; +import { OAuth2AuthorizeModal, UserStore } from "@webpack/common"; import { Logger } from "./Logger"; import { openModal } from "./modal"; -import { relaunch } from "./native"; export const cloudLogger = new Logger("Cloud", "#39b7e0"); export const getCloudUrl = () => new URL(Settings.cloud.url); const getCloudUrlOrigin = () => getCloudUrl().origin; -export async function checkCloudUrlCsp() { - if (IS_WEB) return true; - - const { host } = getCloudUrl(); - if (host === "api.vencord.dev") return true; - if (host === "cloud.equicord.org") return true; - - if (await VencordNative.csp.isDomainAllowed(Settings.cloud.url, ["connect-src"])) { - return true; - } - - const res = await VencordNative.csp.requestAddOverride(Settings.cloud.url, ["connect-src"], "Cloud Sync"); - if (res === "ok") { - Alerts.show({ - title: "Cloud Integration enabled", - body: `${host} has been added to the whitelist. Please restart the app for the changes to take effect.`, - confirmText: "Restart now", - cancelText: "Later!", - onConfirm: relaunch - }); - } - return false; -} - const getUserId = () => { const id = UserStore.getCurrentUser()?.id; if (!id) throw new Error("User not yet logged in"); @@ -104,8 +79,6 @@ export async function authorizeCloud() { return; } - if (!await checkCloudUrlCsp()) return; - try { const oauthConfiguration = await fetch(new URL("/v1/oauth/settings", getCloudUrl())); var { clientId, redirectUri } = await oauthConfiguration.json(); diff --git a/src/utils/settingsSync.ts b/src/utils/settingsSync.ts index f21fe050e..19900d833 100644 --- a/src/utils/settingsSync.ts +++ b/src/utils/settingsSync.ts @@ -22,7 +22,7 @@ import { PlainSettings, Settings } from "@api/Settings"; import { moment, SettingsRouter, Toasts } from "@webpack/common"; import { deflateSync, inflateSync } from "fflate"; -import { checkCloudUrlCsp, getCloudAuth, getCloudUrl } from "./cloud"; +import { getCloudAuth, getCloudUrl } from "./cloud"; import { Logger } from "./Logger"; import { relaunch } from "./native"; import { chooseFile, saveFile } from "./web"; @@ -118,8 +118,6 @@ const cloudSettingsLogger = new Logger("Cloud:Settings", "#39b7e0"); export async function putCloudSettings(manual?: boolean) { const settings = await exportSettings({ minify: true }); - if (!await checkCloudUrlCsp()) return; - try { const res = await fetch(new URL("/v1/settings", getCloudUrl()), { method: "PUT", @@ -164,8 +162,6 @@ export async function putCloudSettings(manual?: boolean) { } export async function getCloudSettings(shouldNotify = true, force = false) { - if (!await checkCloudUrlCsp()) return; - try { const res = await fetch(new URL("/v1/settings", getCloudUrl()), { method: "GET", @@ -268,8 +264,6 @@ export async function getCloudSettings(shouldNotify = true, force = false) { } export async function deleteCloudSettings() { - if (!await checkCloudUrlCsp()) return; - try { const res = await fetch(new URL("/v1/settings", getCloudUrl()), { method: "DELETE",