Added disable assets option

This commit is contained in:
nin0dev 2024-08-03 08:36:14 -04:00
parent 09c42e3c51
commit 077e668234
2 changed files with 53 additions and 33 deletions

View file

@ -153,40 +153,56 @@ export function ReplaceSettings({ appIds, update, save }: SettingsProps) {
onChange(v, i, "newState"); onChange(v, i, "newState");
}} }}
/> />
<Forms.FormText style={{ fontSize: "1.05rem", fontWeight: "500" }} className={Margins.top8}>Large image</Forms.FormText> {
<Forms.FormTitle className={Margins.top8}>Text {setting.newActivityType !== ActivityType.PLAYING && "(also third line)"}</Forms.FormTitle> !setting.disableAssets &&
<TextInput <>
className={Margins.top8} <Forms.FormText style={{ fontSize: "1.05rem", fontWeight: "500" }} className={Margins.top8}>Large image</Forms.FormText>
value={setting.newLargeImageText} <Forms.FormTitle className={Margins.top8}>Text {setting.newActivityType !== ActivityType.PLAYING && "(also third line)"}</Forms.FormTitle>
onChange={async v => { <TextInput
onChange(v, i, "newLargeImageText"); className={Margins.top8}
value={setting.newLargeImageText}
onChange={async v => {
onChange(v, i, "newLargeImageText");
}}
/>
<Forms.FormTitle className={Margins.top8}>URL</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newLargeImageUrl}
onChange={async v => {
onChange(v, i, "newLargeImageUrl");
}}
/>
<Forms.FormText style={{ fontSize: "1.05rem", fontWeight: "500" }} className={Margins.top8}>Small image</Forms.FormText>
<Forms.FormTitle className={Margins.top8}>Text</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newSmallImageText}
onChange={async v => {
onChange(v, i, "newSmallImageText");
}}
/>
<Forms.FormTitle className={Margins.top8}>URL</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newSmallImageUrl}
onChange={async v => {
onChange(v, i, "newSmallImageUrl");
}}
/>
</>
}
<Switch
value={setting.disableAssets}
onChange={value => {
onChange(value, i, "disableAssets");
}} }}
/>
<Forms.FormTitle className={Margins.top8}>URL</Forms.FormTitle>
<TextInput
className={Margins.top8} className={Margins.top8}
value={setting.newLargeImageUrl} hideBorder={true}
onChange={async v => { style={{ marginBottom: "0" }}
onChange(v, i, "newLargeImageUrl"); >
}} Hide assets (large & small images)
/> </Switch>
<Forms.FormText style={{ fontSize: "1.05rem", fontWeight: "500" }} className={Margins.top8}>Small image</Forms.FormText>
<Forms.FormTitle className={Margins.top8}>Text</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newSmallImageText}
onChange={async v => {
onChange(v, i, "newSmallImageText");
}}
/>
<Forms.FormTitle className={Margins.top8}>URL</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newSmallImageUrl}
onChange={async v => {
onChange(v, i, "newSmallImageUrl");
}}
/>
<Switch <Switch
value={setting.disableTimestamps} value={setting.disableTimestamps}
onChange={value => { onChange={value => {

View file

@ -16,6 +16,7 @@ import { parse } from "path";
const APP_IDS_KEY = "ReplaceActivityType_appids"; const APP_IDS_KEY = "ReplaceActivityType_appids";
export type AppIdSetting = { export type AppIdSetting = {
disableAssets: boolean;
disableTimestamps: boolean; disableTimestamps: boolean;
appId: string; appId: string;
enabled: boolean; enabled: boolean;
@ -76,7 +77,8 @@ export const makeEmptyAppId: () => AppIdSetting = () => ({
newSmallImageUrl: "", newSmallImageUrl: "",
newSmallImageText: "", newSmallImageText: "",
newStreamUrl: "", newStreamUrl: "",
disableTimestamps: false disableTimestamps: false,
disableAssets: false
}); });
let appIds = [makeEmptyAppId()]; let appIds = [makeEmptyAppId()];
@ -144,6 +146,8 @@ export default definePlugin({
if (app.newLargeImageUrl) activity.assets.large_image = this.parseField(app.newLargeImageUrl, oldActivity); if (app.newLargeImageUrl) activity.assets.large_image = this.parseField(app.newLargeImageUrl, oldActivity);
if (app.newSmallImageText) activity.assets.small_text = this.parseField(app.newSmallImageText, oldActivity); if (app.newSmallImageText) activity.assets.small_text = this.parseField(app.newSmallImageText, oldActivity);
if (app.newSmallImageUrl) activity.assets.small_image = this.parseField(app.newSmallImageUrl, oldActivity); if (app.newSmallImageUrl) activity.assets.small_image = this.parseField(app.newSmallImageUrl, oldActivity);
// @ts-ignore here we are intentionally nulling assets
if (app.disableAssets) activity.assets = {};
if (app.disableTimestamps) activity.timestamps = {}; if (app.disableTimestamps) activity.timestamps = {};
} }
}); });