mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-26 17:26:22 +00:00
removed rpc fetching (broke)
This commit is contained in:
parent
446fdc1009
commit
13f909bc9a
1 changed files with 28 additions and 48 deletions
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* Vencord, a Discord client mod
|
* Vencord, a Discord client mod
|
||||||
* Copyright (c) 2024 Vendicated and contributors
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { CheckedTextInput } from "@components/CheckedTextInput";
|
import { CheckedTextInput } from "@components/CheckedTextInput";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
|
@ -25,23 +25,6 @@ interface RpcApp {
|
||||||
flags: number;
|
flags: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RPCUtils = findByPropsLazy("fetchApplicationsRPC", "getRemoteIconURL");
|
|
||||||
|
|
||||||
const cachedApps: any = {};
|
|
||||||
async function lookupApp(appId: string): Promise<RpcApp | null> {
|
|
||||||
if (cachedApps[appId]) return cachedApps[appId];
|
|
||||||
const socket: any = {};
|
|
||||||
try {
|
|
||||||
await RPCUtils.fetchApplicationsRPC(socket, appId);
|
|
||||||
console.log(`Lookup finished for ${socket.application.name}`);
|
|
||||||
cachedApps[appId] = socket.application;
|
|
||||||
return socket.application;
|
|
||||||
} catch {
|
|
||||||
console.log(`Lookup failed for ${appId}`);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isValidSnowflake(v: string) {
|
function isValidSnowflake(v: string) {
|
||||||
const regex = /^\d{17,20}$/;
|
const regex = /^\d{17,20}$/;
|
||||||
return regex.test(v) && !Number.isNaN(SnowflakeUtils.extractTimestamp(v));
|
return regex.test(v) && !Number.isNaN(SnowflakeUtils.extractTimestamp(v));
|
||||||
|
@ -49,7 +32,6 @@ function isValidSnowflake(v: string) {
|
||||||
|
|
||||||
export function ReplaceTutorial() {
|
export function ReplaceTutorial() {
|
||||||
const activities: Activity[] = PresenceStore.getActivities(UserStore.getCurrentUser().id);
|
const activities: Activity[] = PresenceStore.getActivities(UserStore.getCurrentUser().id);
|
||||||
console.log(activities);
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Forms.FormTitle tag="h3">IDs of currently running activities</Forms.FormTitle>
|
<Forms.FormTitle tag="h3">IDs of currently running activities</Forms.FormTitle>
|
||||||
|
@ -77,8 +59,7 @@ export function ReplaceSettings({ appIds, update, save }: SettingsProps) {
|
||||||
appIds[index][key] = val;
|
appIds[index][key] = val;
|
||||||
|
|
||||||
if (val && key === "appId") {
|
if (val && key === "appId") {
|
||||||
const tempApp = await lookupApp(val.toString());
|
appIds[index].appName = "Unknown";
|
||||||
appIds[index].appName = tempApp?.name || "Unknown";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appIds[index].appId === "" && index !== appIds.length - 1)
|
if (appIds[index].appId === "" && index !== appIds.length - 1)
|
||||||
|
@ -92,9 +73,9 @@ export function ReplaceSettings({ appIds, update, save }: SettingsProps) {
|
||||||
<>
|
<>
|
||||||
{
|
{
|
||||||
appIds.map((setting, i) =>
|
appIds.map((setting, i) =>
|
||||||
<Card style={{ padding: "1em 1em 0" }}>
|
<Card style={{ padding: "1em" }}>
|
||||||
{
|
{
|
||||||
setting.appName !== "Unknown" ?
|
setting.appId ?
|
||||||
<Switch
|
<Switch
|
||||||
value={setting.enabled}
|
value={setting.enabled}
|
||||||
onChange={value => {
|
onChange={value => {
|
||||||
|
@ -103,10 +84,10 @@ export function ReplaceSettings({ appIds, update, save }: SettingsProps) {
|
||||||
className={Margins.bottom8}
|
className={Margins.bottom8}
|
||||||
hideBorder={true}
|
hideBorder={true}
|
||||||
>
|
>
|
||||||
Edit the {setting.appName} app
|
Edit the app
|
||||||
</Switch> : <Forms.FormTitle tag="h3" className={Margins.bottom8}>Add new application</Forms.FormTitle>
|
</Switch> : <Forms.FormTitle tag="h3">Add new application</Forms.FormTitle>
|
||||||
}
|
}
|
||||||
<Forms.FormTitle>Application ID</Forms.FormTitle>
|
<Forms.FormTitle className={Margins.top8}>Application ID</Forms.FormTitle>
|
||||||
<CheckedTextInput
|
<CheckedTextInput
|
||||||
value={setting.appId}
|
value={setting.appId}
|
||||||
onChange={async v => {
|
onChange={async v => {
|
||||||
|
@ -117,25 +98,24 @@ export function ReplaceSettings({ appIds, update, save }: SettingsProps) {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{
|
{
|
||||||
setting.appName !== "Unknown" ?
|
setting.appId && <>
|
||||||
<>
|
<Forms.FormTitle className={Margins.top8}>New activity type</Forms.FormTitle>
|
||||||
<Forms.FormTitle className={Margins.top8}>New activity type</Forms.FormTitle>
|
<Select
|
||||||
<Select
|
options={[
|
||||||
options={[
|
{ label: "Playing", value: ActivityType.PLAYING },
|
||||||
{ label: "Playing", value: ActivityType.PLAYING },
|
{ label: "Watching", value: ActivityType.WATCHING },
|
||||||
{ label: "Watching", value: ActivityType.WATCHING },
|
{ label: "Listening", value: ActivityType.LISTENING },
|
||||||
{ label: "Listening", value: ActivityType.LISTENING },
|
{ label: "Competing", value: ActivityType.COMPETING },
|
||||||
{ label: "Competing", value: ActivityType.COMPETING },
|
{ label: "Streaming", value: ActivityType.STREAMING }
|
||||||
{ label: "Streaming", value: ActivityType.STREAMING }
|
]}
|
||||||
]}
|
select={value => {
|
||||||
select={value => {
|
onChange(value, i, "activityType");
|
||||||
onChange(value, i, "activityType");
|
}}
|
||||||
}}
|
className={Margins.top8}
|
||||||
className={Margins.top8}
|
isSelected={value => setting.newActivityType === value}
|
||||||
isSelected={value => setting.newActivityType === value}
|
serialize={identity}
|
||||||
serialize={identity}
|
/>
|
||||||
/>
|
</>
|
||||||
</> : null
|
|
||||||
}
|
}
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue