Skip to content

Commit

Permalink
compat
Browse files Browse the repository at this point in the history
  • Loading branch information
yofukashino committed Nov 2, 2023
1 parent bb317f4 commit e5e134c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/patches/Folder.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
import { util } from "replugged";
import { PluginInjector, SettingValues } from "../index";
import { defaultSettings } from "../lib/consts";
import { FolderConstructor } from "../lib/requiredModules";
import Types from "../types";
export default (): void => {
PluginInjector.before(FolderConstructor, "default", (args: [{ expanded: boolean }]) => {
args[0].expanded ||= SettingValues.get("plainFolderIcon", defaultSettings.plainFolderIcon);
return args;
});
PluginInjector.after(
FolderConstructor,
"default",
(_args, res: React.ReactElement & Types.Tree) => {
const IconWrapper = util.findInReactTree(
res,
(c) =>
c?.props &&
Object.hasOwnProperty.call(c?.props, "folderNode") &&
Object.hasOwnProperty.call(c?.props, "hovered"),
) as React.ReactElement & Types.Tree;
if (IconWrapper)
IconWrapper.props.expanded ||= SettingValues.get(
"plainFolderIcon",
defaultSettings.plainFolderIcon,
);

return res;
},
);
};
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { types as DefaultTypes } from "replugged";
import { types as DefaultTypes } from "replugged";
export { Tree } from "replugged/dist/renderer/util";
import { Store } from "replugged/dist/renderer/modules/common/flux";
export interface GenericModule extends Record<string, DefaultTypes.AnyFunction> {}
export interface ElectronModule {
Expand Down

0 comments on commit e5e134c

Please sign in to comment.