aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/openInApp.ts13
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;
}