diff --git a/src/plugins/rpcEditor/ReplaceSettings.tsx b/src/plugins/rpcEditor/ReplaceSettings.tsx index 881d0b252..4811a0751 100644 --- a/src/plugins/rpcEditor/ReplaceSettings.tsx +++ b/src/plugins/rpcEditor/ReplaceSettings.tsx @@ -8,7 +8,7 @@ import { CheckedTextInput } from "@components/CheckedTextInput"; import { Margins } from "@utils/margins"; import { identity } from "@utils/misc"; import { findByPropsLazy } from "@webpack"; -import { Card, Forms, PresenceStore, React, Select, SnowflakeUtils, Switch, UserStore } from "@webpack/common"; +import { Card, Forms, PresenceStore, React, Select, SnowflakeUtils, Switch, TextInput, UserStore } from "@webpack/common"; import { Activity, ActivityType, AppIdSetting, makeEmptyAppId } from "."; @@ -38,7 +38,7 @@ export function ReplaceTutorial() { { activities.length === 0 ? No running activities : activities.map(activity => { return activity.flags !== 48 ? {activity.name}: {activity.application_id} : null; /* hide spotify */ }) } - Available variables + Available variables In all fields, you can put in variables that'll automatically be replaced by their content: @@ -47,6 +47,12 @@ export function ReplaceTutorial() { :large_image:, :large_text:, :small_image:, :small_text: + More details + + Leave a field empty to leave it as is. + + Set a field to "null" to hide it on the presence. + > ); } @@ -58,13 +64,6 @@ export function ReplaceSettings({ appIds, update, save }: SettingsProps) { appIds[index][key] = val; - if (val && key === "appId") { - appIds[index].appName = "Unknown"; - } - - if (appIds[index].appId === "" && index !== appIds.length - 1) - appIds.splice(index, 1); - save(); update(); } @@ -73,9 +72,9 @@ export function ReplaceSettings({ appIds, update, save }: SettingsProps) { <> { appIds.map((setting, i) => - + { - setting.appId ? + isValidSnowflake(setting.appId) ? { @@ -84,10 +83,10 @@ export function ReplaceSettings({ appIds, update, save }: SettingsProps) { className={Margins.bottom8} hideBorder={true} > - Edit the app + Apply edits to app : Add new application } - Application ID + Application ID { @@ -98,7 +97,7 @@ export function ReplaceSettings({ appIds, update, save }: SettingsProps) { } /> { - setting.appId && <> + isValidSnowflake(setting.appId) && <> New activity type { - onChange(value, i, "activityType"); + onChange(value, i, "newActivityType"); }} className={Margins.top8} isSelected={value => setting.newActivityType === value} serialize={identity} /> + { + setting.newActivityType === ActivityType.STREAMING && + <> + Stream URL (must be YouTube or Twitch) + { + onChange(v, i, "newStreamUrl"); + }} + validate={v => { + return /https?:\/\/(www\.)?(twitch\.tv|youtube\.com)\/\w+/.test(v) || "Invalid stream URL"; + }} + /> + + > + } + { + setting.newActivityType !== ActivityType.STREAMING && + <> + New name {setting.newActivityType === ActivityType.PLAYING && "(first line)"} + { + onChange(v, i, "newName"); + }} + /> + > + } + New details {setting.newActivityType === ActivityType.PLAYING ? "(second line)" : "(first line)"} + { + onChange(v, i, "newDetails"); + }} + /> + New state {setting.newActivityType === ActivityType.PLAYING ? "(third line)" : "(second line)"} + { + onChange(v, i, "newState"); + }} + /> + Large image + Text {setting.newActivityType !== ActivityType.PLAYING && "(also third line)"} + { + onChange(v, i, "newLargeImageText"); + }} + /> + URL + { + onChange(v, i, "newLargeImageUrl"); + }} + /> + Small image + Text + { + onChange(v, i, "newSmallImageText"); + }} + /> + URL + { + onChange(v, i, "newSmallImageUrl"); + }} + /> + { + onChange(value, i, "disableTimestamps"); + }} + className={Margins.top8} + hideBorder={true} + style={{ marginBottom: "0" }} + > + Hide timestamps + > } diff --git a/src/plugins/rpcEditor/index.tsx b/src/plugins/rpcEditor/index.tsx index a8f00b4c2..106d233cd 100644 --- a/src/plugins/rpcEditor/index.tsx +++ b/src/plugins/rpcEditor/index.tsx @@ -15,7 +15,7 @@ import { ReplaceSettings, ReplaceTutorial } from "./ReplaceSettings"; const APP_IDS_KEY = "ReplaceActivityType_appids"; export type AppIdSetting = { - appName: string; + disableTimestamps: boolean; appId: string; enabled: boolean; newActivityType: ActivityType; @@ -64,7 +64,6 @@ export const enum ActivityType { } export const makeEmptyAppId: () => AppIdSetting = () => ({ - appName: "Unknown", appId: "", enabled: true, newActivityType: ActivityType.PLAYING, @@ -76,6 +75,7 @@ export const makeEmptyAppId: () => AppIdSetting = () => ({ newSmallImageUrl: "", newSmallImageText: "", newStreamUrl: "", + disableTimestamps: false }); let appIds = [makeEmptyAppId()]; @@ -121,7 +121,6 @@ export default definePlugin({ patchActivity(activity: Activity) { if (!activity) return; - console.log(activity); appIds.forEach(app => { if (app.enabled && app.appId === activity.application_id) { activity.type = app.newActivityType;
@@ -47,6 +47,12 @@ export function ReplaceTutorial() { :large_image:, :large_text:, :small_image:, :small_text: