diff --git a/package.json b/package.json index 723a40cb0..776affcda 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.7.7", + "version": "1.7.8", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { diff --git a/src/Vencord.ts b/src/Vencord.ts index 29e965fa0..655e76c3d 100644 --- a/src/Vencord.ts +++ b/src/Vencord.ts @@ -27,6 +27,7 @@ export { PlainSettings, Settings }; import "./utils/quickCss"; import "./webpack/patchWebpack"; +import { openUpdaterModal } from "@components/VencordSettings/UpdaterTab"; import { StartAt } from "@utils/types"; import { get as dsGet } from "./api/DataStore"; @@ -85,7 +86,7 @@ async function init() { syncSettings(); - if (!IS_WEB) { + if (!IS_WEB && !IS_UPDATER_DISABLED) { try { const isOutdated = await checkForUpdates(); if (!isOutdated) return; @@ -103,16 +104,13 @@ async function init() { return; } - if (Settings.notifyAboutUpdates) - setTimeout(() => showNotification({ - title: "A Vencord update is available!", - body: "Click here to view the update", - permanent: true, - noPersist: true, - onClick() { - SettingsRouter.open("VencordUpdater"); - } - }), 10_000); + setTimeout(() => showNotification({ + title: "A Vencord update is available!", + body: "Click here to view the update", + permanent: true, + noPersist: true, + onClick: openUpdaterModal! + }), 10_000); } catch (err) { UpdateLogger.error("Failed to check for updates", err); } diff --git a/src/api/Settings.ts b/src/api/Settings.ts index 0b7975300..696c12c28 100644 --- a/src/api/Settings.ts +++ b/src/api/Settings.ts @@ -29,7 +29,6 @@ import plugins from "~plugins"; const logger = new Logger("Settings"); export interface Settings { - notifyAboutUpdates: boolean; autoUpdate: boolean; autoUpdateNotification: boolean, useQuickCss: boolean; @@ -78,8 +77,7 @@ export interface Settings { } const DefaultSettings: Settings = { - notifyAboutUpdates: true, - autoUpdate: false, + autoUpdate: true, autoUpdateNotification: true, useQuickCss: true, themeLinks: [], diff --git a/src/components/VencordSettings/UpdaterTab.tsx b/src/components/VencordSettings/UpdaterTab.tsx index 0a5d1f149..680e262d8 100644 --- a/src/components/VencordSettings/UpdaterTab.tsx +++ b/src/components/VencordSettings/UpdaterTab.tsx @@ -22,6 +22,7 @@ import { Flex } from "@components/Flex"; import { Link } from "@components/Link"; import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; +import { ModalCloseButton, ModalContent, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { relaunch } from "@utils/native"; import { useAwaiter } from "@utils/react"; import { changes, checkForUpdates, getRepo, isNewer, update, updateError, UpdateLogger } from "@utils/updater"; @@ -29,7 +30,7 @@ import { Alerts, Button, Card, Forms, Parser, React, Switch, Toasts } from "@web import gitHash from "~git-hash"; -import { SettingsTab, wrapTab } from "./shared"; +import { handleSettingsTabError, SettingsTab, wrapTab } from "./shared"; function withDispatcher(dispatcher: React.Dispatch>, action: () => any) { return async () => { @@ -38,21 +39,24 @@ function withDispatcher(dispatcher: React.Dispatch await action(); } catch (e: any) { UpdateLogger.error("Failed to update", e); + + let err: string; if (!e) { - var err = "An unknown error occurred (error is undefined).\nPlease try again."; + err = "An unknown error occurred (error is undefined).\nPlease try again."; } else if (e.code && e.cmd) { const { code, path, cmd, stderr } = e; if (code === "ENOENT") - var err = `Command \`${path}\` not found.\nPlease install it and try again`; + err = `Command \`${path}\` not found.\nPlease install it and try again`; else { - var err = `An error occurred while running \`${cmd}\`:\n`; + err = `An error occurred while running \`${cmd}\`:\n`; err += stderr || `Code \`${code}\`. See the console for more info`; } } else { - var err = "An unknown error occurred. See the console for more info."; + err = "An unknown error occurred. See the console for more info."; } + Alerts.show({ title: "Oops!", body: ( @@ -186,7 +190,7 @@ function Newer(props: CommonProps) { } function Updater() { - const settings = useSettings(["notifyAboutUpdates", "autoUpdate", "autoUpdateNotification"]); + const settings = useSettings(["autoUpdate", "autoUpdateNotification"]); const [repo, err, repoPending] = useAwaiter(getRepo, { fallbackValue: "Loading..." }); @@ -203,14 +207,6 @@ function Updater() { return ( Updater Settings - settings.notifyAboutUpdates = v} - note="Shows a notification on startup" - disabled={settings.autoUpdate} - > - Get notified about new updates - settings.autoUpdate = v} @@ -253,3 +249,20 @@ function Updater() { } export default IS_UPDATER_DISABLED ? null : wrapTab(Updater, "Updater"); + +export const openUpdaterModal = IS_UPDATER_DISABLED ? null : function () { + const UpdaterTab = wrapTab(Updater, "Updater"); + + try { + openModal(wrapTab((modalProps: ModalProps) => ( + + + + + + + ), "UpdaterModal")); + } catch { + handleSettingsTabError(); + } +}; diff --git a/src/components/VencordSettings/settingsStyles.css b/src/components/VencordSettings/settingsStyles.css index 01cbcd557..310dba9af 100644 --- a/src/components/VencordSettings/settingsStyles.css +++ b/src/components/VencordSettings/settingsStyles.css @@ -65,3 +65,11 @@ /* discord also sets cursor: default which prevents the cursor from showing as text */ cursor: initial; } + +.vc-updater-modal { + padding: 1.5em !important; +} + +.vc-updater-modal-close-button { + float: right; +} diff --git a/src/components/VencordSettings/shared.tsx b/src/components/VencordSettings/shared.tsx index 6dd34c46f..1c5f37d82 100644 --- a/src/components/VencordSettings/shared.tsx +++ b/src/components/VencordSettings/shared.tsx @@ -42,11 +42,11 @@ export function SettingsTab({ title, children }: PropsWithChildren<{ title: stri ); } -const onError = onlyOnce(handleComponentFailed); +export const handleSettingsTabError = onlyOnce(handleComponentFailed); -export function wrapTab(component: ComponentType, tab: string) { +export function wrapTab(component: ComponentType, tab: string) { return ErrorBoundary.wrap(component, { message: `Failed to render the ${tab} tab. If this issue persists, try using the installer to reinstall!`, - onError, + onError: handleSettingsTabError, }); } diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx index 569c3f0ac..1aea0d6ee 100644 --- a/src/plugins/_core/settings.tsx +++ b/src/plugins/_core/settings.tsx @@ -45,14 +45,14 @@ export default definePlugin({ replacement: { get match() { switch (Settings.plugins.Settings.settingsLocation) { - case "top": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.USER_SETTINGS\}/; - case "aboveNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.BILLING_SETTINGS\}/; - case "belowNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.APP_SETTINGS\}/; + case "top": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.USER_SETTINGS/; + case "aboveNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.BILLING_SETTINGS/; + case "belowNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.APP_SETTINGS/; case "belowActivity": return /(?<=\{section:(\i\.\i)\.DIVIDER},)\{section:"changelog"/; case "bottom": return /\{section:(\i\.\i)\.CUSTOM,\s*element:.+?}/; case "aboveActivity": default: - return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.ACTIVITY_SETTINGS\}/; + return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.ACTIVITY_SETTINGS/; } }, replace: "...$self.makeSettingsCategories($1),$&" diff --git a/src/plugins/customRPC/index.tsx b/src/plugins/customRPC/index.tsx index 35fb64d1c..334372e38 100644 --- a/src/plugins/customRPC/index.tsx +++ b/src/plugins/customRPC/index.tsx @@ -22,9 +22,10 @@ import { Devs } from "@utils/constants"; import { isTruthy } from "@utils/guards"; import { useAwaiter } from "@utils/react"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpack"; import { ApplicationAssetUtils, FluxDispatcher, Forms, GuildStore, React, SelectedChannelStore, SelectedGuildStore, UserStore } from "@webpack/common"; +const useProfileThemeStyle = findByCodeLazy("profileThemeStyle:", "--profile-gradient-primary-color"); const ActivityComponent = findComponentByCodeLazy("onOpenGameProfile"); const ActivityClassName = findByPropsLazy("activity", "buttonColor"); @@ -392,6 +393,8 @@ export default definePlugin({ settingsAboutComponent: () => { const activity = useAwaiter(createActivity); + const { profileThemeStyle } = useProfileThemeStyle({}); + return ( <> @@ -405,7 +408,7 @@ export default definePlugin({ If you want to use image link, download your image and reupload the image to Imgur and get the image link by right-clicking the image and select "Copy image address". -
+
{activity[0] && { + for (const name of ["memberSinceWrapper", "memberSinceContainer"]) { + const mod = find(filters.byProps(name), { isIndirect: true }); + if (mod) return mod[name]; + } + handleModuleNotFound("findByProps", "memberSinceWrapper/memberSinceContainer"); + return ""; +}); const { getCreatedAtDate } = findByPropsLazy("getCreatedAtDate"); const clydeMoreInfo = findByPropsLazy("clydeMoreInfo"); const locale = findByPropsLazy("getLocale"); @@ -49,7 +59,7 @@ export default definePlugin({ Friends Since -
+
{!!getCurrentChannel()?.guild_id && (