Compare commits
No commits in common. "55146db760fdcbc5eb06af31288a5af944720758" and "fd0fbace2ec7ac0ac5895b87d995197449506725" have entirely different histories.
55146db760
...
fd0fbace2e
|
@ -90,20 +90,19 @@ export function removeGlobalContextMenuPatch(patch: GlobalContextMenuPatchCallba
|
|||
* A helper function for finding the children array of a group nested inside a context menu based on the id(s) of its children
|
||||
* @param id The id of the child. If an array is specified, all ids will be tried
|
||||
* @param children The context menu children
|
||||
* @param matchSubstring Whether to check if the id is a substring of the child id
|
||||
*/
|
||||
export function findGroupChildrenByChildId(id: string | string[], children: Array<ReactElement | null | undefined>, matchSubstring = false): Array<ReactElement | null | undefined> | null {
|
||||
export function findGroupChildrenByChildId(id: string | string[], children: Array<ReactElement | null>): Array<ReactElement | null> | null {
|
||||
for (const child of children) {
|
||||
if (child == null) continue;
|
||||
|
||||
if (Array.isArray(child)) {
|
||||
const found = findGroupChildrenByChildId(id, child, matchSubstring);
|
||||
const found = findGroupChildrenByChildId(id, child);
|
||||
if (found !== null) return found;
|
||||
}
|
||||
|
||||
if (
|
||||
(Array.isArray(id) && id.some(id => matchSubstring ? child.props?.id?.includes(id) : child.props?.id === id))
|
||||
|| (matchSubstring ? child.props?.id?.includes(id) : child.props?.id === id)
|
||||
(Array.isArray(id) && id.some(id => child.props?.id === id))
|
||||
|| child.props?.id === id
|
||||
) return children;
|
||||
|
||||
let nextChildren = child.props?.children;
|
||||
|
@ -113,7 +112,7 @@ export function findGroupChildrenByChildId(id: string | string[], children: Arra
|
|||
child.props.children = nextChildren;
|
||||
}
|
||||
|
||||
const found = findGroupChildrenByChildId(id, nextChildren, matchSubstring);
|
||||
const found = findGroupChildrenByChildId(id, nextChildren);
|
||||
if (found !== null) return found;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,8 +200,8 @@ export default definePlugin({
|
|||
predicate: () => settings.store.sidebar,
|
||||
replacement: {
|
||||
// Render the Better Folders sidebar
|
||||
match: /(container.{0,50}({className:\i\.guilds,themeOverride:\i})\))/,
|
||||
replace: "$1,$self.FolderSideBar({...$2})"
|
||||
match: /(?<=({className:\i\.guilds,themeOverride:\i})\))/,
|
||||
replace: ",$self.FolderSideBar({...$1})"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -203,15 +203,6 @@ export default definePlugin({
|
|||
settings,
|
||||
|
||||
patches: [
|
||||
// Patch the emoji picker in voice calls to not be bypassed by fake nitro
|
||||
{
|
||||
find: "emojiItemDisabled]",
|
||||
predicate: () => settings.store.enableEmojiBypass,
|
||||
replacement: {
|
||||
match: /CHAT/,
|
||||
replace: "STATUS"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: ".PREMIUM_LOCKED;",
|
||||
group: true,
|
||||
|
|
|
@ -16,25 +16,16 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { migratePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { NoopComponent } from "@utils/react";
|
||||
import definePlugin from "@utils/types";
|
||||
import { filters, findByPropsLazy, waitFor } from "@webpack";
|
||||
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");
|
||||
|
||||
interface CopyIdMenuItemProps {
|
||||
id: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
let CopyIdMenuItem: (props: CopyIdMenuItemProps) => React.ReactElement | null = NoopComponent;
|
||||
waitFor(filters.componentByCode('"devmode-copy-id-".concat'), m => CopyIdMenuItem = m);
|
||||
|
||||
function MessageMenu({ message, channel, onHeightUpdate }) {
|
||||
const canReport = message.author &&
|
||||
!(message.author.id === UserStore.getCurrentUser().id || message.author.system);
|
||||
|
@ -57,25 +48,9 @@ function MessageMenu({ message, channel, onHeightUpdate }) {
|
|||
itemSrc: void 0,
|
||||
itemSafeSrc: void 0,
|
||||
itemTextContent: void 0,
|
||||
|
||||
isFullSearchContextMenu: true
|
||||
});
|
||||
}
|
||||
|
||||
interface MessageActionsProps {
|
||||
message: Message;
|
||||
isFullSearchContextMenu?: boolean;
|
||||
}
|
||||
|
||||
const contextMenuPatch: NavContextMenuPatchCallback = (children, props: MessageActionsProps) => {
|
||||
if (props?.isFullSearchContextMenu == null) return;
|
||||
|
||||
const group = findGroupChildrenByChildId("devmode-copy-id", children, true);
|
||||
group?.push(
|
||||
CopyIdMenuItem({ id: props.message.author.id, label: i18n.Messages.COPY_ID_AUTHOR })
|
||||
);
|
||||
};
|
||||
|
||||
migratePluginSettings("FullSearchContext", "SearchReply");
|
||||
export default definePlugin({
|
||||
name: "FullSearchContext",
|
||||
|
@ -90,7 +65,7 @@ export default definePlugin({
|
|||
}
|
||||
}],
|
||||
|
||||
handleContextMenu(event: React.MouseEvent, message: Message) {
|
||||
handleContextMenu(event: MouseEvent, message: Message) {
|
||||
const channel = ChannelStore.getChannel(message.channel_id);
|
||||
if (!channel) return;
|
||||
|
||||
|
@ -103,9 +78,5 @@ export default definePlugin({
|
|||
onHeightUpdate={contextMenuProps.onHeightUpdate}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
||||
contextMenus: {
|
||||
"message-actions": contextMenuPatch
|
||||
}
|
||||
});
|
||||
|
|
|
@ -61,7 +61,8 @@ const settings = definePluginSettings({
|
|||
type: OptionType.SLIDER,
|
||||
description: "Intensity of message coloring.",
|
||||
markers: makeRange(0, 100, 10),
|
||||
default: 30
|
||||
default: 30,
|
||||
restartNeeded: true
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ export default definePlugin({
|
|||
name: "UserVoiceShow",
|
||||
description: "Shows an indicator when a user is in a Voice Channel",
|
||||
authors: [Devs.Nuckyz, Devs.LordElias],
|
||||
dependencies: ["MemberListDecoratorsAPI", "MessageDecorationsAPI"],
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
|
|
Loading…
Reference in a new issue