Skip to content

Commit

Permalink
customrpc fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
E-boi committed Jun 22, 2024
1 parent 00a4e3c commit f6ef268
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 234 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"prettier": "^2.8.8",
"prompts": "^2.4.2",
"react-dnd": "^16.0.1",
"replugged": "^4.7.6",
"replugged": "^4.8.0",
"semver": "^7.5.4",
"tsx": "^3.12.7",
"typescript": "^4.9.5",
Expand Down
1 change: 0 additions & 1 deletion plugins/customrpc/components/RPCSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { ModalProps } from "replugged/dist/renderer/modules/common/modal";
import { RPC } from "..";
import Save from "./Save";
import { TextInputType } from "replugged/components";
// import TextInput from "./TextInput";

const {
Modal: { ModalRoot, ModalHeader, ModalContent, ModalCloseButton },
Expand Down
3 changes: 2 additions & 1 deletion plugins/customrpc/components/Save.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ let Notice:

export default ({ onReset, onSave }: { onReset: () => void; onSave: () => void }) => {
if (!SlideIn) {
SlideIn = webpack.getBySource('inputRange:[0,1],outputRange:["150%","0%"]');
const m = webpack.getBySource('inputRange:[0,1],outputRange:["150%","0%"]');
if (m) SlideIn = webpack.getFunctionBySource(m, 'inputRange:[0,1],outputRange:["150%","0%"]');
}
if (!Notice) {
Notice = webpack.getBySource("onSaveButtonColor");
Expand Down
34 changes: 8 additions & 26 deletions plugins/customrpc/components/UserActivities.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,22 @@
import { common, webpack } from "replugged";
import { AnyFunction, ObjectExports } from "replugged/dist/types";
import { userActivity } from ".";
import { UserActivity } from ".";
import { Store } from "replugged/dist/renderer/modules/common/flux";
import { User } from "discord-types/general";

const ActivityStore = webpack.getByStoreName<
Store & {
getActivities: (...args: any[]) => unknown[];
getLocalPresence: AnyFunction;
}
>("SelfPresenceStore");
const user = webpack.getByProps<{ getCurrentUser: AnyFunction }>("getCurrentUser");
const UserStore = webpack.getByStoreName<Store & { getCurrentUser: () => User }>("UserStore");
// const user = webpack.getByProps<{ getCurrentUser: AnyFunction }>("getCurrentUser");

const classes = webpack.getByProps<Record<string, string>>("profileColors");

export default () => {
if (!ActivityStore || !userActivity) return null;
if (!UserActivity) return null;

const activities = common.flux.useStateFromStores([ActivityStore], () =>
ActivityStore.getActivities(),
);

// just for types using "userActivity.default" component says "userActivity" may be null
const UserActivity = userActivity.default;
const user = UserStore!.getCurrentUser();

return (
<div className={`${classes?.profileColors} rprpc-activities`}>
{activities?.map((a) => (
<UserActivity
activity={a}
className="rprpc-activity"
source="Profile Modal"
type="ProfileV2"
useStoreStream={false}
user={user?.getCurrentUser()}
/>
))}
<div>
<UserActivity user={user} type="ProfileV2" />
</div>
);
};
14 changes: 5 additions & 9 deletions plugins/customrpc/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { User } from "discord-types/general";
import { FC, ReactNode } from "react";
import { webpack } from "replugged";
import {
Expand All @@ -9,15 +10,8 @@ import {
} from "replugged/dist/types";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
// export const UserActivity = webpack.getFunctionBySource<FC<any>>(
// await webpack.waitForModule(
// webpack.filters.bySource('"activity","user","useStoreStream","showActions","hideHeader"'),
// ),
// '"activity","user","useStoreStream","showActions","hideHeader"',
// );

export const userActivity: { default: FC<any> } | undefined = await webpack.waitForProps(
"UserActivityTypes",
export const UserActivity = webpack.getBySource<FC<{ type: "ProfileV2"; user: User }>>(
"user:i,type:s,showActions:t,onClose:m",
);

// const FormItemMod = webpack.getBySource(
Expand Down Expand Up @@ -72,6 +66,8 @@ export const TransitionGroup = getFunctionByProto<
),
);

console.log(TransitionGroup);

export function getExportsForProto<
P extends string = string,
T extends ModuleExportsWithProps<P> = ModuleExportsWithProps<P>,
Expand Down
Loading

0 comments on commit f6ef268

Please sign in to comment.