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,6 +153,9 @@ export function ReplaceSettings({ appIds, update, save }: SettingsProps) {
onChange(v, i, "newState");
}}
/>
{
!setting.disableAssets &&
<>
<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>
<TextInput
@ -187,6 +190,19 @@ export function ReplaceSettings({ appIds, update, save }: SettingsProps) {
onChange(v, i, "newSmallImageUrl");
}}
/>
</>
}
<Switch
value={setting.disableAssets}
onChange={value => {
onChange(value, i, "disableAssets");
}}
className={Margins.top8}
hideBorder={true}
style={{ marginBottom: "0" }}
>
Hide assets (large & small images)
</Switch>
<Switch
value={setting.disableTimestamps}
onChange={value => {

View file

@ -16,6 +16,7 @@ import { parse } from "path";
const APP_IDS_KEY = "ReplaceActivityType_appids";
export type AppIdSetting = {
disableAssets: boolean;
disableTimestamps: boolean;
appId: string;
enabled: boolean;
@ -76,7 +77,8 @@ export const makeEmptyAppId: () => AppIdSetting = () => ({
newSmallImageUrl: "",
newSmallImageText: "",
newStreamUrl: "",
disableTimestamps: false
disableTimestamps: false,
disableAssets: false
});
let appIds = [makeEmptyAppId()];
@ -144,6 +146,8 @@ export default definePlugin({
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.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 = {};
}
});