mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
Compare commits
8 commits
b77434f582
...
d15fcbdad6
Author | SHA1 | Date | |
---|---|---|---|
|
d15fcbdad6 | ||
|
c7e5295da0 | ||
|
947240b1f7 | ||
|
5b5faf8239 | ||
|
7e2ff411f7 | ||
|
33c9dadaf1 | ||
|
58b8aee426 | ||
|
6875ff0d9f |
8 changed files with 217 additions and 82 deletions
5
src/plugins/fullSearchContext/README.md
Normal file
5
src/plugins/fullSearchContext/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# FullSearchContext
|
||||
|
||||
Makes the message context menu in message search results have all options you'd expect.
|
||||
|
||||
![](https://github.com/user-attachments/assets/472d1327-3935-44c7-b7c4-0978b5348550)
|
82
src/plugins/fullSearchContext/index.tsx
Normal file
82
src/plugins/fullSearchContext/index.tsx
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* 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 { migratePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { ChannelStore, ContextMenuApi, i18n, UserStore } from "@webpack/common";
|
||||
import { Message } from "discord-types/general";
|
||||
import type { MouseEvent } from "react";
|
||||
|
||||
const { useMessageMenu } = findByPropsLazy("useMessageMenu");
|
||||
|
||||
function MessageMenu({ message, channel, onHeightUpdate }) {
|
||||
const canReport = message.author &&
|
||||
!(message.author.id === UserStore.getCurrentUser().id || message.author.system);
|
||||
|
||||
return useMessageMenu({
|
||||
navId: "message-actions",
|
||||
ariaLabel: i18n.Messages.MESSAGE_UTILITIES_A11Y_LABEL,
|
||||
|
||||
message,
|
||||
channel,
|
||||
canReport,
|
||||
onHeightUpdate,
|
||||
onClose: () => ContextMenuApi.closeContextMenu(),
|
||||
|
||||
textSelection: "",
|
||||
favoriteableType: null,
|
||||
favoriteableId: null,
|
||||
favoriteableName: null,
|
||||
itemHref: void 0,
|
||||
itemSrc: void 0,
|
||||
itemSafeSrc: void 0,
|
||||
itemTextContent: void 0,
|
||||
});
|
||||
}
|
||||
|
||||
migratePluginSettings("FullSearchContext", "SearchReply");
|
||||
export default definePlugin({
|
||||
name: "FullSearchContext",
|
||||
description: "Makes the message context menu in message search results have all options you'd expect",
|
||||
authors: [Devs.Ven, Devs.Aria],
|
||||
|
||||
patches: [{
|
||||
find: "onClick:this.handleMessageClick,",
|
||||
replacement: {
|
||||
match: /this(?=\.handleContextMenu\(\i,\i\))/,
|
||||
replace: "$self"
|
||||
}
|
||||
}],
|
||||
|
||||
handleContextMenu(event: MouseEvent, message: Message) {
|
||||
const channel = ChannelStore.getChannel(message.channel_id);
|
||||
if (!channel) return;
|
||||
|
||||
event.stopPropagation();
|
||||
|
||||
ContextMenuApi.openContextMenu(event, contextMenuProps =>
|
||||
<MessageMenu
|
||||
message={message}
|
||||
channel={channel}
|
||||
onHeightUpdate={contextMenuProps.onHeightUpdate}
|
||||
/>
|
||||
);
|
||||
}
|
||||
});
|
|
@ -1,6 +0,0 @@
|
|||
# SearchReply
|
||||
|
||||
Adds a reply button to search results.
|
||||
|
||||
![the plugin in action](https://github.com/Vendicated/Vencord/assets/45497981/07e741d3-0f97-4e5c-82b0-80712ecf2cbb)
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* 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 { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { ReplyIcon } from "@components/Icons";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByCodeLazy } from "@webpack";
|
||||
import { ChannelStore, i18n, Menu, PermissionsBits, PermissionStore, SelectedChannelStore } from "@webpack/common";
|
||||
import { Message } from "discord-types/general";
|
||||
|
||||
|
||||
const replyToMessage = findByCodeLazy(".TEXTAREA_FOCUS)", "showMentionToggle:");
|
||||
|
||||
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { message }: { message: Message; }) => {
|
||||
// make sure the message is in the selected channel
|
||||
if (SelectedChannelStore.getChannelId() !== message.channel_id) return;
|
||||
const channel = ChannelStore.getChannel(message?.channel_id);
|
||||
if (!channel) return;
|
||||
if (channel.guild_id && !PermissionStore.can(PermissionsBits.SEND_MESSAGES, channel)) return;
|
||||
|
||||
// dms and group chats
|
||||
const dmGroup = findGroupChildrenByChildId("pin", children);
|
||||
if (dmGroup && !dmGroup.some(child => child?.props?.id === "reply")) {
|
||||
const pinIndex = dmGroup.findIndex(c => c?.props.id === "pin");
|
||||
dmGroup.splice(pinIndex + 1, 0, (
|
||||
<Menu.MenuItem
|
||||
id="reply"
|
||||
label={i18n.Messages.MESSAGE_ACTION_REPLY}
|
||||
icon={ReplyIcon}
|
||||
action={(e: React.MouseEvent) => replyToMessage(channel, message, e)}
|
||||
/>
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
// servers
|
||||
const serverGroup = findGroupChildrenByChildId("mark-unread", children);
|
||||
if (serverGroup && !serverGroup.some(child => child?.props?.id === "reply")) {
|
||||
serverGroup.unshift((
|
||||
<Menu.MenuItem
|
||||
id="reply"
|
||||
label={i18n.Messages.MESSAGE_ACTION_REPLY}
|
||||
icon={ReplyIcon}
|
||||
action={(e: React.MouseEvent) => replyToMessage(channel, message, e)}
|
||||
/>
|
||||
));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export default definePlugin({
|
||||
name: "SearchReply",
|
||||
description: "Adds a reply button to search results",
|
||||
authors: [Devs.Aria],
|
||||
contextMenus: {
|
||||
"message": messageContextMenuPatch
|
||||
}
|
||||
});
|
|
@ -172,7 +172,7 @@ export default definePlugin({
|
|||
// This is the thread "spine" that shows in the left
|
||||
find: "M11 9H4C2.89543 9 2 8.10457 2 7V1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1V7C0 9.20914 1.79086 11 4 11H11C11.5523 11 12 10.5523 12 10C12 9.44771 11.5523 9 11 9Z",
|
||||
replacement: {
|
||||
match: /mentionsCount:\i.+?null(?<=channel:(\i).+?)/,
|
||||
match: /mentionsCount:\i.{0,50}?null(?<=channel:(\i).+?)/,
|
||||
replace: "$&,$self.TypingIndicator($1.id)"
|
||||
}
|
||||
}
|
||||
|
|
9
src/plugins/unreadCountBadge/README.md
Normal file
9
src/plugins/unreadCountBadge/README.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# UnreadCountBadge
|
||||
|
||||
Shows unread message count badges on channels in the channel list
|
||||
|
||||
![](https://github.com/user-attachments/assets/58beb269-259c-47aa-84dc-60f2354e6207)
|
||||
|
||||
Setting to replace the white dot
|
||||
|
||||
![](https://github.com/user-attachments/assets/c0612bc2-d62b-45ca-86dd-105dcc484071)
|
101
src/plugins/unreadCountBadge/index.tsx
Normal file
101
src/plugins/unreadCountBadge/index.tsx
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import "./styles.css";
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
||||
import { ReadStateStore, useStateFromStores } from "@webpack/common";
|
||||
import { Channel } from "discord-types/general";
|
||||
|
||||
const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore");
|
||||
const JoinedThreadsStore = findStoreLazy("JoinedThreadsStore");
|
||||
const { NumberBadge } = findByPropsLazy("NumberBadge");
|
||||
|
||||
const settings = definePluginSettings({
|
||||
showOnMutedChannels: {
|
||||
description: "Show unread count on muted channels",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false,
|
||||
},
|
||||
notificationCountLimit: {
|
||||
description: "Show +99 instead of true amount",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false,
|
||||
},
|
||||
replaceWhiteDot: {
|
||||
description: "Replace the white dot with the badge",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false,
|
||||
restartNeeded: true,
|
||||
},
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "UnreadCountBadge",
|
||||
authors: [Devs.Joona],
|
||||
description: "Shows unread message count badges on channels in the channel list",
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
// Kanged from typingindicators
|
||||
{
|
||||
find: "UNREAD_IMPORTANT:",
|
||||
replacement: [
|
||||
{
|
||||
match: /\.name\),.{0,120}\.children.+?:null/,
|
||||
replace: "$&,$self.CountBadge({channel: arguments[0].channel,})",
|
||||
predicate: () => !settings.store.replaceWhiteDot
|
||||
},
|
||||
{
|
||||
match: /\(0,\i\.jsx\)\("div",{className:\i\(\)\(\i\.unread,\i\?\i\.unreadImportant:void 0\)}\)/,
|
||||
replace: "$self.CountBadge({channel: arguments[0].channel, whiteDot:$&})",
|
||||
predicate: () => settings.store.replaceWhiteDot
|
||||
}
|
||||
]
|
||||
},
|
||||
// Threads
|
||||
{
|
||||
// This is the thread "spine" that shows in the left
|
||||
find: "M11 9H4C2.89543 9 2 8.10457 2 7V1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1V7C0 9.20914 1.79086 11 4 11H11C11.5523 11 12 10.5523 12 10C12 9.44771 11.5523 9 11 9Z",
|
||||
replacement: [
|
||||
{
|
||||
match: /mentionsCount:\i.{0,50}?null/,
|
||||
replace: "$&,$self.CountBadge({channel: arguments[0].thread})",
|
||||
predicate: () => !settings.store.replaceWhiteDot
|
||||
},
|
||||
{
|
||||
match: /\(0,\i\.jsx\)\("div",{className:\i\(\)\(\i\.unread,\i\.unreadImportant\)}\)/,
|
||||
replace: "$self.CountBadge({channel: arguments[0].thread, whiteDot:$&})",
|
||||
predicate: () => settings.store.replaceWhiteDot
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
|
||||
CountBadge: ErrorBoundary.wrap(({ channel, whiteDot }: { channel: Channel, whiteDot?: JSX.Element; }) => {
|
||||
const unreadCount = useStateFromStores([ReadStateStore], () => ReadStateStore.getUnreadCount(channel.id));
|
||||
if (!unreadCount) return whiteDot || null;
|
||||
|
||||
if (!settings.store.showOnMutedChannels && (UserGuildSettingsStore.isChannelMuted(channel.guild_id, channel.id) || JoinedThreadsStore.isMuted(channel.id)))
|
||||
return null;
|
||||
const className = `vc-unreadCountBadge${whiteDot ? "-dot" : ""}${channel.threadMetadata ? "-thread" : ""}`;
|
||||
return (
|
||||
<NumberBadge
|
||||
color="var(--brand-500)"
|
||||
className={className}
|
||||
count={
|
||||
unreadCount > 99 && settings.store.notificationCountLimit
|
||||
? "+99"
|
||||
: unreadCount
|
||||
}
|
||||
/>
|
||||
);
|
||||
}, { noop: true }),
|
||||
});
|
19
src/plugins/unreadCountBadge/styles.css
Normal file
19
src/plugins/unreadCountBadge/styles.css
Normal file
|
@ -0,0 +1,19 @@
|
|||
.vc-unreadCountBadge {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.vc-unreadCountBadge-dot {
|
||||
position: absolute;
|
||||
top: 25%;
|
||||
margin-left: -3%;
|
||||
scale: 0.9;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.vc-unreadCountBadge-dot-thread {
|
||||
position: absolute;
|
||||
top: 20%;
|
||||
margin-left: -18%;
|
||||
scale: 0.9;
|
||||
z-index: 1;
|
||||
}
|
Loading…
Reference in a new issue