diff options
author | V <vendicated@riseup.net> | 2023-07-04 17:52:52 +0200 |
---|---|---|
committer | V <vendicated@riseup.net> | 2023-07-04 17:52:52 +0200 |
commit | 994c3b3c92ccb510facd726a3ceecdb987263f79 (patch) | |
tree | c03694417fdf9415a5979d45863adc92a4a4b64a | |
parent | c696c186e82bd84c665ae5ba0dfc2a89863b435a (diff) | |
download | Vencord-994c3b3c92ccb510facd726a3ceecdb987263f79.tar.gz Vencord-994c3b3c92ccb510facd726a3ceecdb987263f79.tar.bz2 Vencord-994c3b3c92ccb510facd726a3ceecdb987263f79.zip |
OpenInApp: Fix bot buttons
-rw-r--r-- | src/plugins/openInApp.ts | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/plugins/openInApp.ts b/src/plugins/openInApp.ts index f3a5983..7d3d7d1 100644 --- a/src/plugins/openInApp.ts +++ b/src/plugins/openInApp.ts @@ -20,7 +20,6 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { showToast, Toasts } from "@webpack/common"; -import { MouseEvent } from "react"; const ShortUrlMatcher = /^https:\/\/(spotify\.link|s\.team)\/.+$/; const SpotifyMatcher = /^https:\/\/open\.spotify\.com\/(track|album|artist|playlist|user)\/(.+)(?:\?.+?)?$/; @@ -77,12 +76,12 @@ export default definePlugin({ } ], - async handleLink(data: { href: string; }, event: MouseEvent) { + async handleLink(data: { href: string; }, event?: MouseEvent) { if (!data) return false; let url = data.href; if (!IS_WEB && ShortUrlMatcher.test(url)) { - event.preventDefault(); + event?.preventDefault(); // CORS jumpscare url = await VencordNative.pluginHelpers.OpenInApp.resolveRedirect(url); } @@ -96,7 +95,7 @@ export default definePlugin({ const [, type, id] = match; VencordNative.native.openExternal(`spotify:${type}:${id}`); - event.preventDefault(); + event?.preventDefault(); return true; } @@ -106,7 +105,7 @@ export default definePlugin({ if (!SteamMatcher.test(url)) break steam; 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 showToast("Opened link in Steam", Toasts.Type.SUCCESS); @@ -120,13 +119,13 @@ export default definePlugin({ if (!match) break epic; VencordNative.native.openExternal(`com.epicgames.launcher://store/${match[1]}`); - event.preventDefault(); + event?.preventDefault(); return true; } // in case short url didn't end up being something we can handle - if (event.defaultPrevented) { + if (event?.defaultPrevented) { window.open(url, "_blank"); return true; } |