feat(plugin): ResurrectHome (#2232)
This commit is contained in:
parent
23ff82fa62
commit
4f0c0a12dc
5
src/plugins/resurrectHome/README.md
Normal file
5
src/plugins/resurrectHome/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# ResurrectHome
|
||||
|
||||
Brings back the phased out [Server Home](https://support.discord.com/hc/en-us/articles/6156116949911-Server-Home-Beta) feature!
|
||||
|
||||
![](https://private-user-images.githubusercontent.com/47677887/309572891-a9ee7354-9e5e-4b81-8faf-304d9c44f512.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDk0OTE5MTIsIm5iZiI6MTcwOTQ5MTYxMiwicGF0aCI6Ii80NzY3Nzg4Ny8zMDk1NzI4OTEtYTllZTczNTQtOWU1ZS00YjgxLThmYWYtMzA0ZDljNDRmNTEyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAzMDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMzAzVDE4NDY1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBhYzUxMWY1MzQxNTA4NDE1MWU0YjAxNzM1NzI1YWJkMTNiZmNkNjRmYTRkZDg1ZDE5NzdkMjM0MGVjMDA0OWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TPYWPRWHTJstfviT9HOaBWFkbBhokyxiDC-gOVL2dqs)
|
125
src/plugins/resurrectHome/index.tsx
Normal file
125
src/plugins/resurrectHome/index.tsx
Normal file
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { ContextMenuApi, Menu } from "@webpack/common";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
forceServerHome: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Force the Server Guide to be the Server Home tab when it is enabled.",
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
const contextMenuPatch: NavContextMenuPatchCallback = (children, props) => () => {
|
||||
if (!props?.guild) return;
|
||||
|
||||
const group = findGroupChildrenByChildId("hide-muted-channels", children);
|
||||
|
||||
group?.unshift(
|
||||
<Menu.MenuCheckboxItem
|
||||
key="force-server-home"
|
||||
id="force-server-home"
|
||||
label="Force Server Home"
|
||||
checked={settings.store.forceServerHome}
|
||||
action={() => {
|
||||
settings.store.forceServerHome = !settings.store.forceServerHome;
|
||||
ContextMenuApi.closeContextMenu();
|
||||
}}
|
||||
/>
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
export default definePlugin({
|
||||
name: "ResurrectHome",
|
||||
description: "Re-enables the Server Home tab when there isn't a Server Guide. Also has an option to force the Server Home over the Server Guide, which is accessible through right-clicking the Server Guide.",
|
||||
authors: [Devs.Dolfies, Devs.Nuckyz],
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
// Force home deprecation override
|
||||
{
|
||||
find: "GuildFeatures.GUILD_HOME_DEPRECATION_OVERRIDE",
|
||||
all: true,
|
||||
replacement: [
|
||||
{
|
||||
match: /\i\.hasFeature\(\i\.GuildFeatures\.GUILD_HOME_DEPRECATION_OVERRIDE\)/g,
|
||||
replace: "true"
|
||||
}
|
||||
],
|
||||
},
|
||||
// Disable feedback prompts
|
||||
{
|
||||
find: "GuildHomeFeedbackExperiment.definition.id",
|
||||
replacement: [
|
||||
{
|
||||
match: /return{showFeedback:\i,setOnDismissedFeedback:(\i)}/,
|
||||
replace: "return{showFeedback:false,setOnDismissedFeedback:$1}"
|
||||
}
|
||||
]
|
||||
},
|
||||
// This feature was never finished, so the patch is disabled
|
||||
|
||||
// Enable guild feed render mode selector
|
||||
// {
|
||||
// find: "2022-01_home_feed_toggle",
|
||||
// replacement: [
|
||||
// {
|
||||
// match: /showSelector:!1/,
|
||||
// replace: "showSelector:true"
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
|
||||
// Fix focusMessage clearing previously cached messages and causing a loop when fetching messages around home messages
|
||||
{
|
||||
find: '"MessageActionCreators"',
|
||||
replacement: {
|
||||
match: /(?<=focusMessage\(\i\){.+?)(?=focus:{messageId:(\i)})/,
|
||||
replace: "before:$1,"
|
||||
}
|
||||
},
|
||||
// Force Server Home instead of Server Guide
|
||||
{
|
||||
find: "61eef9_2",
|
||||
replacement: {
|
||||
match: /(?<=getMutableGuildChannelsForGuild\(\i\)\);)(?=if\(null==\i\|\|)/,
|
||||
replace: "if($self.useForceServerHome())return false;"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
start() {
|
||||
addContextMenuPatch("guild-context", contextMenuPatch);
|
||||
},
|
||||
|
||||
stop() {
|
||||
removeContextMenuPatch("guild-context", contextMenuPatch);
|
||||
},
|
||||
|
||||
useForceServerHome() {
|
||||
const { forceServerHome } = settings.use(["forceServerHome"]);
|
||||
|
||||
return forceServerHome;
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue