Merge branch 'dev' into immediate-finds

This commit is contained in:
Nuckyz 2024-05-03 04:55:19 -03:00
commit f8a7d1d634
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
2 changed files with 8 additions and 11 deletions

View file

@ -23,11 +23,13 @@ import definePlugin, { OptionType } from "@utils/types";
import { findByProps } from "@webpack"; import { findByProps } from "@webpack";
import { FluxDispatcher, PermissionsBits, PermissionStore, UserStore } from "@webpack/common"; import { FluxDispatcher, PermissionsBits, PermissionStore, UserStore } from "@webpack/common";
const MessageActions = findByProps("deleteMessage", "startEditMessage");
const EditStore = findByProps("isEditing", "isEditingAny");
let isDeletePressed = false; let isDeletePressed = false;
const keydown = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = true); const keydown = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = true);
const keyup = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = false); const keyup = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = false);
const settings = definePluginSettings({ const settings = definePluginSettings({
enableDeleteOnClick: { enableDeleteOnClick: {
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
@ -60,9 +62,6 @@ export default definePlugin({
settings, settings,
start() { start() {
const MessageActions = findByProps("deleteMessage", "startEditMessage");
const EditStore = findByProps("isEditing", "isEditingAny");
document.addEventListener("keydown", keydown); document.addEventListener("keydown", keydown);
document.addEventListener("keyup", keyup); document.addEventListener("keyup", keyup);

View file

@ -197,8 +197,7 @@ export default definePlugin({
replacement: [ replacement: [
// make the tag show the right text // make the tag show the right text
{ {
// FIXME: Remove the BOT_TAG_BOT variant when the change arrives in stable match: /(switch\((\i)\){.+?)case (\i(?:\.\i)?)\.BOT:default:(\i)=.{0,40}(\i\.\i\.Messages)\.APP_TAG/,
match: /(switch\((\i)\){.+?)case (\i(?:\.\i)?)\.BOT:default:(\i)=.{0,40}(\i\.\i\.Messages)\.(?:APP_TAG|BOT_TAG_BOT)/,
replace: (_, origSwitch, variant, tags, displayedText, strings) => replace: (_, origSwitch, variant, tags, displayedText, strings) =>
`${origSwitch}default:{${displayedText} = $self.getTagText(${tags}[${variant}], ${strings})}` `${origSwitch}default:{${displayedText} = $self.getTagText(${tags}[${variant}], ${strings})}`
}, },
@ -321,20 +320,19 @@ export default definePlugin({
isOPTag: (tag: number) => tag === Tag.Types.ORIGINAL_POSTER || tags.some(t => tag === Tag.Types[`${t.name}-OP`]), isOPTag: (tag: number) => tag === Tag.Types.ORIGINAL_POSTER || tags.some(t => tag === Tag.Types[`${t.name}-OP`]),
// FIXME: Remove the BOT_TAG_BOT variants from strings when the change arrives in stable
getTagText(passedTagName: string, strings: Record<string, string>) { getTagText(passedTagName: string, strings: Record<string, string>) {
if (!passedTagName) return strings.APP_TAG ?? strings.BOT_TAG_BOT; if (!passedTagName) return strings.APP_TAG;
const [tagName, variant] = passedTagName.split("-"); const [tagName, variant] = passedTagName.split("-");
const tag = tags.find(({ name }) => tagName === name); const tag = tags.find(({ name }) => tagName === name);
if (!tag) return strings.APP_TAG ?? strings.BOT_TAG_BOT; if (!tag) return strings.APP_TAG;
if (variant === "BOT" && tagName !== "WEBHOOK" && this.settings.store.dontShowForBots) return strings.APP_TAG ?? strings.BOT_TAG_BOT; if (variant === "BOT" && tagName !== "WEBHOOK" && this.settings.store.dontShowForBots) return strings.APP_TAG;
const tagText = settings.store.tagSettings?.[tag.name]?.text || tag.displayName; const tagText = settings.store.tagSettings?.[tag.name]?.text || tag.displayName;
switch (variant) { switch (variant) {
case "OP": case "OP":
return `${strings.BOT_TAG_FORUM_ORIGINAL_POSTER}${tagText}`; return `${strings.BOT_TAG_FORUM_ORIGINAL_POSTER}${tagText}`;
case "BOT": case "BOT":
return `${strings.APP_TAG ?? strings.BOT_TAG_BOT}${tagText}`; return `${strings.APP_TAG}${tagText}`;
default: default:
return tagText; return tagText;
} }