Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
a0babc3709
5 changed files with 36 additions and 25 deletions
|
|
@ -16,9 +16,10 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { BaseText } from "@components/BaseText";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { handleComponentFailed } from "@components/handleComponentFailed";
|
||||
import { ModalCloseButton, ModalContent, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import { onlyOnce } from "@utils/onlyOnce";
|
||||
import type { ComponentType, PropsWithChildren } from "react";
|
||||
|
||||
|
|
@ -43,13 +44,17 @@ export function wrapTab(component: ComponentType<any>, tab: string) {
|
|||
export function openSettingsTabModal(Tab: ComponentType<any>) {
|
||||
try {
|
||||
openModal(wrapTab((modalProps: ModalProps) => (
|
||||
<ModalRoot {...modalProps} size={ModalSize.MEDIUM}>
|
||||
<ModalRoot {...modalProps} size={ModalSize.MEDIUM} className="vc-settings-modal-root">
|
||||
<ModalHeader>
|
||||
<BaseText size="lg" weight="semibold" style={{ flexGrow: 1 }}>{Tab.displayName?.replace("SettingsTab", "") || "Settings"}</BaseText>
|
||||
<ModalCloseButton onClick={modalProps.onClose} />
|
||||
</ModalHeader>
|
||||
|
||||
<ModalContent className="vc-settings-modal">
|
||||
<ModalCloseButton onClick={modalProps.onClose} className="vc-settings-modal-close" />
|
||||
<Tab />
|
||||
</ModalContent>
|
||||
</ModalRoot>
|
||||
), Tab.displayName || "Settings Tab"));
|
||||
), Tab.displayName || "SettingsTab"));
|
||||
} catch {
|
||||
handleSettingsTabError();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,10 +90,10 @@
|
|||
height: 1.25em;
|
||||
}
|
||||
|
||||
.vc-settings-modal {
|
||||
padding: 1.5em !important;
|
||||
.vc-settings-modal-root {
|
||||
background: var(--background-base-low);
|
||||
}
|
||||
|
||||
.vc-settings-modal-close {
|
||||
float: right;
|
||||
.vc-settings-modal {
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ export default definePlugin({
|
|||
group: true,
|
||||
replacement: [
|
||||
{
|
||||
match: /(\.AVATAR,children:.+?renderPopout:\(?(\i)(?:,\i\))?=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/,
|
||||
match: /(\.AVATAR,children:.+?renderPopout:\((\i),\i\)=>)\{(.+?)\}(?=,position)(?<=currentUser:(\i).+?)/,
|
||||
replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},originalRenderPopout:()=>{${originalPopout}}})`
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (
|
|||
mlDeleted: true,
|
||||
});
|
||||
} else {
|
||||
message.editHistory = [];
|
||||
updateMessage(channel_id, id, { editHistory: [] });
|
||||
}
|
||||
}}
|
||||
/>,
|
||||
|
|
@ -853,8 +853,8 @@ export default definePlugin({
|
|||
replace: '$&$1.type==="MESSAGE_GROUP_DELETED"||',
|
||||
},
|
||||
{
|
||||
match: /(\i).type===\i\.\i\.MESSAGE_GROUP_BLOCKED\?.*?:/,
|
||||
replace: '$&$1.type==="MESSAGE_GROUP_DELETED"?$self.DELETED_MESSAGE_COUNT:',
|
||||
match: /(\i).type===\i\.\i\.MESSAGE_GROUP_BLOCKED\?(\i)=.*?:/,
|
||||
replace: '$&$1.type==="MESSAGE_GROUP_DELETED"?$2=$self.DELETED_MESSAGE_COUNT:',
|
||||
},
|
||||
],
|
||||
predicate: () => settings.store.collapseDeleted,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { BaseText } from "@components/BaseText";
|
||||
import { CodeBlock } from "@components/CodeBlock";
|
||||
|
|
@ -125,31 +125,36 @@ const settings = definePluginSettings({
|
|||
{ label: "Left Click to view the raw content.", value: "Left", default: true },
|
||||
{ label: "Right click to view the raw content.", value: "Right" }
|
||||
]
|
||||
},
|
||||
messageContextMenu: {
|
||||
description: "Show in message context menu",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
function MakeContextCallback(name: "Guild" | "Role" | "User" | "Channel"): NavContextMenuPatchCallback {
|
||||
function MakeContextCallback(name: "Guild" | "Role" | "User" | "Channel" | "Message"): NavContextMenuPatchCallback {
|
||||
return (children, props) => {
|
||||
const value = props[name.toLowerCase()];
|
||||
if (!value) return;
|
||||
if (props.label === getIntlMessage("CHANNEL_ACTIONS_MENU_LABEL")) return; // random shit like notification settings
|
||||
const isMessage = name === "Message";
|
||||
if (isMessage && !settings.store.messageContextMenu) return;
|
||||
|
||||
const lastChild = children.at(-1);
|
||||
if (lastChild?.key === "developer-actions") {
|
||||
const p = lastChild.props;
|
||||
if (!Array.isArray(p.children))
|
||||
p.children = [p.children];
|
||||
|
||||
children = p.children;
|
||||
}
|
||||
|
||||
// typescript parser goes crazy if this is inline
|
||||
const id = `vc-view-${name.toLowerCase()}-raw`;
|
||||
children.splice(-1, 0,
|
||||
const action = isMessage
|
||||
? () => openViewRawModalMessage(value)
|
||||
: () => openViewRawModal(JSON.stringify(value, null, 4), name);
|
||||
|
||||
const devContainer = findGroupChildrenByChildId(`devmode-copy-id-${value.id}`, children);
|
||||
|
||||
(devContainer ?? children).splice(-1, 0,
|
||||
<Menu.MenuItem
|
||||
id={id}
|
||||
label="View Raw"
|
||||
action={() => openViewRawModal(JSON.stringify(value, null, 4), name)}
|
||||
action={action}
|
||||
icon={CopyIcon}
|
||||
/>
|
||||
);
|
||||
|
|
@ -188,7 +193,8 @@ export default definePlugin({
|
|||
"thread-context": MakeContextCallback("Channel"),
|
||||
"gdm-context": MakeContextCallback("Channel"),
|
||||
"user-context": MakeContextCallback("User"),
|
||||
"dev-context": devContextCallback
|
||||
"dev-context": devContextCallback,
|
||||
"message": MakeContextCallback("Message"),
|
||||
},
|
||||
|
||||
messagePopoverButton: {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue