From 1cb295b1b97b4e19d49a709541905bdf8949c4a0 Mon Sep 17 00:00:00 2001 From: Inbestigator <119569726+Inbestigator@users.noreply.github.com> Date: Thu, 21 Mar 2024 18:16:24 -0700 Subject: [PATCH] new plugin: OverrideForumDefaults (#2272) Co-authored-by: Vendicated --- src/plugins/overrideForumDefaults/index.tsx | 54 +++++++++++++++++++++ src/utils/constants.ts | 4 ++ 2 files changed, 58 insertions(+) create mode 100644 src/plugins/overrideForumDefaults/index.tsx diff --git a/src/plugins/overrideForumDefaults/index.tsx b/src/plugins/overrideForumDefaults/index.tsx new file mode 100644 index 000000000..be106ac8a --- /dev/null +++ b/src/plugins/overrideForumDefaults/index.tsx @@ -0,0 +1,54 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { definePluginSettings } from "@api/Settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; + +const settings = definePluginSettings({ + defaultLayout: { + type: OptionType.SELECT, + options: [ + { label: "List", value: 1, default: true }, + { label: "Gallery", value: 2 } + ], + description: "Which layout to use as default" + }, + defaultSortOrder: { + type: OptionType.SELECT, + options: [ + { label: "Recently Active", value: 0, default: true }, + { label: "Date Posted", value: 1 } + ], + description: "Which sort order to use as default" + } +}); + +export default definePlugin({ + name: "OverrideForumDefaults", + description: "Allows you to override default forum layout/sort order. you can still change it on a per-channel basis", + authors: [Devs.Inbestigator], + patches: [ + { + find: "getDefaultLayout(){", + replacement: [ + { + match: /getDefaultLayout\(\){/, + replace: "$&return $self.getLayout();" + }, + { + match: /getDefaultSortOrder\(\){/, + replace: "$&return $self.getSortOrder();" + } + ] + } + ], + + getLayout: () => settings.store.defaultLayout, + getSortOrder: () => settings.store.defaultSortOrder, + + settings +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 5b540895a..f3626aaa0 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -418,6 +418,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "Elvyra", id: 708275751816003615n, }, + Inbestigator: { + name: "Inbestigator", + id: 761777382041714690n + }, newwares: { name: "newwares", id: 421405303951851520n