Skip to content

Commit

Permalink
Merge pull request #3 from nexpid/main
Browse files Browse the repository at this point in the history
fix message long press crashing
  • Loading branch information
FieryFlames authored Oct 16, 2023
2 parents c8fb044 + 8f665a9 commit 0243368
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"build": "node build.mjs"
},
"dependencies": {
"@nexpid/vdp-shared": "1.0.1",
"@swc/helpers": "^0.4.14"
},
"devDependencies": {
Expand Down
17 changes: 10 additions & 7 deletions src/patches/MessageLongPressActionSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { React } from "@vendetta/metro/common";
import { after, before } from "@vendetta/patcher";
import { storage } from "@vendetta/plugin";
import { getAssetIDByName } from "@vendetta/ui/assets";
import { Forms } from "@vendetta/ui/components";
import { showToast } from "@vendetta/ui/toasts";
import { findInReactTree } from "@vendetta/utils";

const LazyActionSheet = findByProps("openLazy", "hideActionSheet");
import { RedesignRow } from "@nexpid/vdp-shared";

// Components
const { FormRow, FormIcon } = Forms;
const LazyActionSheet = findByProps("openLazy", "hideActionSheet");

const JSON_CODEBLOCK_PATTERN = /^```(?:json)\n([\s\S]*?)```$/gm

Expand Down Expand Up @@ -45,7 +44,11 @@ export default function patchMessageLongPressActionSheet() {
// Don't add anything if we have no importable rules
if (!rules || rules.length == 0) return;

let buttons = res?.props?.children?.props?.children?.props?.children[1];
const buttons = findInReactTree(
res,
(x) => x?.[0]?.type?.name === "ButtonRow"
);
if (!buttons) return;

for (const rule of rules) {
const importRuleCallback = () => {
Expand All @@ -54,8 +57,8 @@ export default function patchMessageLongPressActionSheet() {
LazyActionSheet.hideActionSheet();
};

const importRuleButton = (<FormRow
leading={<FormIcon style={{ opacity: 1 }} source={Download} />}
const importRuleButton = (<RedesignRow
icon={Download}
label={`Import ${rule.name}`}
onPress={importRuleCallback}
/>);
Expand Down

0 comments on commit 0243368

Please sign in to comment.