Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bf34b2ae43 | ||
|
cb5f23d9b5 | ||
|
cd2cbfa0ef | ||
|
232e340fab | ||
|
8027daa2b0 | ||
|
0f7b9f588e | ||
|
93482ac2a5 | ||
|
994c3b3c92 |
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vencord",
|
"name": "vencord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.3.2",
|
"version": "1.3.3",
|
||||||
"description": "The cutest Discord client mod",
|
"description": "The cutest Discord client mod",
|
||||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
@ -86,7 +86,7 @@ function SettingsSyncSection() {
|
|||||||
<Button
|
<Button
|
||||||
size={Button.Sizes.SMALL}
|
size={Button.Sizes.SMALL}
|
||||||
disabled={!sectionEnabled}
|
disabled={!sectionEnabled}
|
||||||
onClick={() => putCloudSettings()}
|
onClick={() => putCloudSettings(true)}
|
||||||
>Sync to Cloud</Button>
|
>Sync to Cloud</Button>
|
||||||
<Tooltip text="This will overwrite your local settings with the ones on the cloud. Use wisely!">
|
<Tooltip text="This will overwrite your local settings with the ones on the cloud. Use wisely!">
|
||||||
{({ onMouseLeave, onMouseEnter }) => (
|
{({ onMouseLeave, onMouseEnter }) => (
|
||||||
|
@ -20,7 +20,7 @@ import { definePluginSettings } from "@api/Settings";
|
|||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { showToast, Toasts } from "@webpack/common";
|
import { showToast, Toasts } from "@webpack/common";
|
||||||
import { MouseEvent } from "react";
|
import type { MouseEvent } from "react";
|
||||||
|
|
||||||
const ShortUrlMatcher = /^https:\/\/(spotify\.link|s\.team)\/.+$/;
|
const ShortUrlMatcher = /^https:\/\/(spotify\.link|s\.team)\/.+$/;
|
||||||
const SpotifyMatcher = /^https:\/\/open\.spotify\.com\/(track|album|artist|playlist|user)\/(.+)(?:\?.+?)?$/;
|
const SpotifyMatcher = /^https:\/\/open\.spotify\.com\/(track|album|artist|playlist|user)\/(.+)(?:\?.+?)?$/;
|
||||||
@ -77,12 +77,12 @@ export default definePlugin({
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
async handleLink(data: { href: string; }, event: MouseEvent) {
|
async handleLink(data: { href: string; }, event?: MouseEvent) {
|
||||||
if (!data) return false;
|
if (!data) return false;
|
||||||
|
|
||||||
let url = data.href;
|
let url = data.href;
|
||||||
if (!IS_WEB && ShortUrlMatcher.test(url)) {
|
if (!IS_WEB && ShortUrlMatcher.test(url)) {
|
||||||
event.preventDefault();
|
event?.preventDefault();
|
||||||
// CORS jumpscare
|
// CORS jumpscare
|
||||||
url = await VencordNative.pluginHelpers.OpenInApp.resolveRedirect(url);
|
url = await VencordNative.pluginHelpers.OpenInApp.resolveRedirect(url);
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ export default definePlugin({
|
|||||||
const [, type, id] = match;
|
const [, type, id] = match;
|
||||||
VencordNative.native.openExternal(`spotify:${type}:${id}`);
|
VencordNative.native.openExternal(`spotify:${type}:${id}`);
|
||||||
|
|
||||||
event.preventDefault();
|
event?.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ export default definePlugin({
|
|||||||
if (!SteamMatcher.test(url)) break steam;
|
if (!SteamMatcher.test(url)) break steam;
|
||||||
|
|
||||||
VencordNative.native.openExternal(`steam://openurl/${url}`);
|
VencordNative.native.openExternal(`steam://openurl/${url}`);
|
||||||
event.preventDefault();
|
event?.preventDefault();
|
||||||
|
|
||||||
// Steam does not focus itself so show a toast so it's slightly less confusing
|
// Steam does not focus itself so show a toast so it's slightly less confusing
|
||||||
showToast("Opened link in Steam", Toasts.Type.SUCCESS);
|
showToast("Opened link in Steam", Toasts.Type.SUCCESS);
|
||||||
@ -120,13 +120,13 @@ export default definePlugin({
|
|||||||
if (!match) break epic;
|
if (!match) break epic;
|
||||||
|
|
||||||
VencordNative.native.openExternal(`com.epicgames.launcher://store/${match[1]}`);
|
VencordNative.native.openExternal(`com.epicgames.launcher://store/${match[1]}`);
|
||||||
event.preventDefault();
|
event?.preventDefault();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// in case short url didn't end up being something we can handle
|
// in case short url didn't end up being something we can handle
|
||||||
if (event.defaultPrevented) {
|
if (event?.defaultPrevented) {
|
||||||
window.open(url, "_blank");
|
window.open(url, "_blank");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import type { Channel, Role } from "discord-types/general";
|
|||||||
|
|
||||||
import HiddenChannelLockScreen, { setChannelBeginHeaderComponent } from "./components/HiddenChannelLockScreen";
|
import HiddenChannelLockScreen, { setChannelBeginHeaderComponent } from "./components/HiddenChannelLockScreen";
|
||||||
|
|
||||||
const ChannelListClasses = findByPropsLazy("channelName", "subtitle", "modeMuted", "iconContainer");
|
const ChannelListClasses = findByPropsLazy("channelEmoji", "unread", "icon");
|
||||||
|
|
||||||
export const VIEW_CHANNEL = 1n << 10n;
|
export const VIEW_CHANNEL = 1n << 10n;
|
||||||
const CONNECT = 1n << 20n;
|
const CONNECT = 1n << 20n;
|
||||||
@ -472,7 +472,7 @@ export default definePlugin({
|
|||||||
|
|
||||||
HiddenChannelLockScreen: (channel: any) => <HiddenChannelLockScreen channel={channel} />,
|
HiddenChannelLockScreen: (channel: any) => <HiddenChannelLockScreen channel={channel} />,
|
||||||
|
|
||||||
LockIcon: () => (
|
LockIcon: ErrorBoundary.wrap(() => (
|
||||||
<svg
|
<svg
|
||||||
className={ChannelListClasses.icon}
|
className={ChannelListClasses.icon}
|
||||||
height="18"
|
height="18"
|
||||||
@ -483,7 +483,7 @@ export default definePlugin({
|
|||||||
>
|
>
|
||||||
<path className="shc-evenodd-fill-current-color" d="M17 11V7C17 4.243 14.756 2 12 2C9.242 2 7 4.243 7 7V11C5.897 11 5 11.896 5 13V20C5 21.103 5.897 22 7 22H17C18.103 22 19 21.103 19 20V13C19 11.896 18.103 11 17 11ZM12 18C11.172 18 10.5 17.328 10.5 16.5C10.5 15.672 11.172 15 12 15C12.828 15 13.5 15.672 13.5 16.5C13.5 17.328 12.828 18 12 18ZM15 11H9V7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V11Z" />
|
<path className="shc-evenodd-fill-current-color" d="M17 11V7C17 4.243 14.756 2 12 2C9.242 2 7 4.243 7 7V11C5.897 11 5 11.896 5 13V20C5 21.103 5.897 22 7 22H17C18.103 22 19 21.103 19 20V13C19 11.896 18.103 11 17 11ZM12 18C11.172 18 10.5 17.328 10.5 16.5C10.5 15.672 11.172 15 12 15C12.828 15 13.5 15.672 13.5 16.5C13.5 17.328 12.828 18 12 18ZM15 11H9V7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V11Z" />
|
||||||
</svg>
|
</svg>
|
||||||
),
|
), { noop: true }),
|
||||||
|
|
||||||
HiddenChannelIcon: ErrorBoundary.wrap(() => (
|
HiddenChannelIcon: ErrorBoundary.wrap(() => (
|
||||||
<Tooltip text="Hidden Channel">
|
<Tooltip text="Hidden Channel">
|
||||||
|
@ -21,7 +21,6 @@ import "./spotifyStyles.css";
|
|||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { ImageIcon, LinkIcon, OpenExternalIcon } from "@components/Icons";
|
import { ImageIcon, LinkIcon, OpenExternalIcon } from "@components/Icons";
|
||||||
import { Link } from "@components/Link";
|
|
||||||
import { debounce } from "@utils/debounce";
|
import { debounce } from "@utils/debounce";
|
||||||
import { openImageModal } from "@utils/discord";
|
import { openImageModal } from "@utils/discord";
|
||||||
import { classes, copyWithToast } from "@utils/misc";
|
import { classes, copyWithToast } from "@utils/misc";
|
||||||
@ -254,6 +253,16 @@ function AlbumContextMenu({ track }: { track: Track; }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeLinkProps(name: string, condition: unknown, path: string) {
|
||||||
|
if (!condition) return {};
|
||||||
|
|
||||||
|
return {
|
||||||
|
role: "link",
|
||||||
|
onClick: () => SpotifyStore.openExternal(path),
|
||||||
|
onContextMenu: makeContextMenu(name, path)
|
||||||
|
} satisfies React.HTMLAttributes<HTMLElement>;
|
||||||
|
}
|
||||||
|
|
||||||
function Info({ track }: { track: Track; }) {
|
function Info({ track }: { track: Track; }) {
|
||||||
const img = track?.album?.image;
|
const img = track?.album?.image;
|
||||||
|
|
||||||
@ -289,12 +298,8 @@ function Info({ track }: { track: Track; }) {
|
|||||||
variant="text-sm/semibold"
|
variant="text-sm/semibold"
|
||||||
id={cl("song-title")}
|
id={cl("song-title")}
|
||||||
className={cl("ellipoverflow")}
|
className={cl("ellipoverflow")}
|
||||||
role={track.id ? "link" : undefined}
|
|
||||||
title={track.name}
|
title={track.name}
|
||||||
onClick={track.id ? () => {
|
{...makeLinkProps("Song", track.id, `/track/${track.id}`)}
|
||||||
SpotifyStore.openExternal(`/track/${track.id}`);
|
|
||||||
} : void 0}
|
|
||||||
onContextMenu={track.id ? makeContextMenu("Song", `/track/${track.id}`) : void 0}
|
|
||||||
>
|
>
|
||||||
{track.name}
|
{track.name}
|
||||||
</Forms.FormText>
|
</Forms.FormText>
|
||||||
@ -303,16 +308,14 @@ function Info({ track }: { track: Track; }) {
|
|||||||
by
|
by
|
||||||
{track.artists.map((a, i) => (
|
{track.artists.map((a, i) => (
|
||||||
<React.Fragment key={a.name}>
|
<React.Fragment key={a.name}>
|
||||||
<Link
|
<span
|
||||||
className={cl("artist")}
|
className={cl("artist")}
|
||||||
disabled={!a.id}
|
|
||||||
href={`https://open.spotify.com/artist/${a.id}`}
|
|
||||||
style={{ fontSize: "inherit" }}
|
style={{ fontSize: "inherit" }}
|
||||||
title={a.name}
|
title={a.name}
|
||||||
onContextMenu={makeContextMenu("Artist", `/artist/${a.id}`)}
|
{...makeLinkProps("Artist", a.id, `/artist/${a.id}`)}
|
||||||
>
|
>
|
||||||
{a.name}
|
{a.name}
|
||||||
</Link>
|
</span>
|
||||||
{i !== track.artists.length - 1 && <span className={cl("comma")}>{", "}</span>}
|
{i !== track.artists.length - 1 && <span className={cl("comma")}>{", "}</span>}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
@ -321,17 +324,15 @@ function Info({ track }: { track: Track; }) {
|
|||||||
{track.album.name && (
|
{track.album.name && (
|
||||||
<Forms.FormText variant="text-sm/normal" className={cl("ellipoverflow")}>
|
<Forms.FormText variant="text-sm/normal" className={cl("ellipoverflow")}>
|
||||||
on
|
on
|
||||||
<Link id={cl("album-title")}
|
<span
|
||||||
href={`https://open.spotify.com/album/${track.album.id}`}
|
id={cl("album-title")}
|
||||||
target="_blank"
|
|
||||||
className={cl("album")}
|
className={cl("album")}
|
||||||
disabled={!track.album.id}
|
|
||||||
style={{ fontSize: "inherit" }}
|
style={{ fontSize: "inherit" }}
|
||||||
title={track.album.name}
|
title={track.album.name}
|
||||||
onContextMenu={makeContextMenu("Album", `/album/${track.album.id}`)}
|
{...makeLinkProps("Album", track.album.id, `/album/${track.album.id}`)}
|
||||||
>
|
>
|
||||||
{track.album.name}
|
{track.album.name}
|
||||||
</Link>
|
</span>
|
||||||
</Forms.FormText>
|
</Forms.FormText>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -131,8 +131,8 @@
|
|||||||
color: var(--header-secondary);
|
color: var(--header-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-spotify-artist:hover,
|
.vc-spotify-artist[role="link"]:hover,
|
||||||
#vc-spotify-album-title:hover,
|
#vc-spotify-album-title[role="link"]:hover,
|
||||||
#vc-spotify-song-title[role="link"]:hover {
|
#vc-spotify-song-title[role="link"]:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -27,8 +27,8 @@ const unconfigurable = ["arguments", "caller", "prototype"];
|
|||||||
|
|
||||||
const handler: ProxyHandler<any> = {};
|
const handler: ProxyHandler<any> = {};
|
||||||
|
|
||||||
const GET_KEY = Symbol.for("vencord.lazy.get");
|
const kGET = Symbol.for("vencord.lazy.get");
|
||||||
const CACHED_KEY = Symbol.for("vencord.lazy.cached");
|
const kCACHE = Symbol.for("vencord.lazy.cached");
|
||||||
|
|
||||||
for (const method of [
|
for (const method of [
|
||||||
"apply",
|
"apply",
|
||||||
@ -46,11 +46,11 @@ for (const method of [
|
|||||||
"setPrototypeOf"
|
"setPrototypeOf"
|
||||||
]) {
|
]) {
|
||||||
handler[method] =
|
handler[method] =
|
||||||
(target: any, ...args: any[]) => Reflect[method](target[GET_KEY](), ...args);
|
(target: any, ...args: any[]) => Reflect[method](target[kGET](), ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.ownKeys = target => {
|
handler.ownKeys = target => {
|
||||||
const v = target[GET_KEY]();
|
const v = target[kGET]();
|
||||||
const keys = Reflect.ownKeys(v);
|
const keys = Reflect.ownKeys(v);
|
||||||
for (const key of unconfigurable) {
|
for (const key of unconfigurable) {
|
||||||
if (!keys.includes(key)) keys.push(key);
|
if (!keys.includes(key)) keys.push(key);
|
||||||
@ -62,7 +62,7 @@ handler.getOwnPropertyDescriptor = (target, p) => {
|
|||||||
if (typeof p === "string" && unconfigurable.includes(p))
|
if (typeof p === "string" && unconfigurable.includes(p))
|
||||||
return Reflect.getOwnPropertyDescriptor(target, p);
|
return Reflect.getOwnPropertyDescriptor(target, p);
|
||||||
|
|
||||||
const descriptor = Reflect.getOwnPropertyDescriptor(target[GET_KEY](), p);
|
const descriptor = Reflect.getOwnPropertyDescriptor(target[kGET](), p);
|
||||||
|
|
||||||
if (descriptor) Object.defineProperty(target, p, descriptor);
|
if (descriptor) Object.defineProperty(target, p, descriptor);
|
||||||
return descriptor;
|
return descriptor;
|
||||||
@ -72,15 +72,22 @@ handler.getOwnPropertyDescriptor = (target, p) => {
|
|||||||
* Wraps the result of {@see makeLazy} in a Proxy you can consume as if it wasn't lazy.
|
* Wraps the result of {@see makeLazy} in a Proxy you can consume as if it wasn't lazy.
|
||||||
* On first property access, the lazy is evaluated
|
* On first property access, the lazy is evaluated
|
||||||
* @param factory lazy factory
|
* @param factory lazy factory
|
||||||
|
* @param attempts how many times to try to evaluate the lazy before giving up
|
||||||
* @returns Proxy
|
* @returns Proxy
|
||||||
*
|
*
|
||||||
* Note that the example below exists already as an api, see {@link findByPropsLazy}
|
* Note that the example below exists already as an api, see {@link findByPropsLazy}
|
||||||
* @example const mod = proxyLazy(() => findByProps("blah")); console.log(mod.blah);
|
* @example const mod = proxyLazy(() => findByProps("blah")); console.log(mod.blah);
|
||||||
*/
|
*/
|
||||||
export function proxyLazy<T>(factory: () => T): T {
|
export function proxyLazy<T>(factory: () => T, attempts = 5): T {
|
||||||
const proxyDummy: { (): void;[CACHED_KEY]?: T;[GET_KEY](): T; } = Object.assign(function () { }, {
|
let tries = 0;
|
||||||
[CACHED_KEY]: void 0,
|
const proxyDummy = Object.assign(function () { }, {
|
||||||
[GET_KEY]: () => proxyDummy[CACHED_KEY] ??= factory(),
|
[kCACHE]: void 0 as T | undefined,
|
||||||
|
[kGET]() {
|
||||||
|
if (!proxyDummy[kCACHE] && attempts > tries++) {
|
||||||
|
proxyDummy[kCACHE] = factory();
|
||||||
|
}
|
||||||
|
return proxyDummy[kCACHE];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Proxy(proxyDummy, handler) as any;
|
return new Proxy(proxyDummy, handler) as any;
|
||||||
|
@ -41,10 +41,10 @@ export async function importSettings(data: string) {
|
|||||||
throw new Error("Invalid Settings. Is this even a Vencord Settings file?");
|
throw new Error("Invalid Settings. Is this even a Vencord Settings file?");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function exportSettings() {
|
export async function exportSettings({ minify }: { minify?: boolean; } = {}) {
|
||||||
const settings = JSON.parse(VencordNative.settings.get());
|
const settings = JSON.parse(VencordNative.settings.get());
|
||||||
const quickCss = await VencordNative.quickCss.get();
|
const quickCss = await VencordNative.quickCss.get();
|
||||||
return JSON.stringify({ settings, quickCss }, null, 4);
|
return JSON.stringify({ settings, quickCss }, null, minify ? undefined : 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function downloadSettingsBackup() {
|
export async function downloadSettingsBackup() {
|
||||||
@ -121,8 +121,8 @@ export async function uploadSettingsBackup(showToast = true): Promise<void> {
|
|||||||
// Cloud settings
|
// Cloud settings
|
||||||
const cloudSettingsLogger = new Logger("Cloud:Settings", "#39b7e0");
|
const cloudSettingsLogger = new Logger("Cloud:Settings", "#39b7e0");
|
||||||
|
|
||||||
export async function putCloudSettings() {
|
export async function putCloudSettings(manual?: boolean) {
|
||||||
const settings = await exportSettings();
|
const settings = await exportSettings({ minify: true });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(new URL("/v1/settings", getCloudUrl()), {
|
const res = await fetch(new URL("/v1/settings", getCloudUrl()), {
|
||||||
@ -149,6 +149,14 @@ export async function putCloudSettings() {
|
|||||||
VencordNative.settings.set(JSON.stringify(PlainSettings, null, 4));
|
VencordNative.settings.set(JSON.stringify(PlainSettings, null, 4));
|
||||||
|
|
||||||
cloudSettingsLogger.info("Settings uploaded to cloud successfully");
|
cloudSettingsLogger.info("Settings uploaded to cloud successfully");
|
||||||
|
|
||||||
|
if (manual) {
|
||||||
|
showNotification({
|
||||||
|
title: "Cloud Settings",
|
||||||
|
body: "Synchronized settings to the cloud!",
|
||||||
|
noPersist: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
cloudSettingsLogger.error("Failed to sync up", e);
|
cloudSettingsLogger.error("Failed to sync up", e);
|
||||||
showNotification({
|
showNotification({
|
||||||
|
Reference in New Issue
Block a user