Skip to content

Commit

Permalink
BetterFolders: Fix pending clan applications (#2867)
Browse files Browse the repository at this point in the history
  • Loading branch information
sadan4 authored Sep 12, 2024
1 parent f27361f commit 926ae50
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/plugins/betterFolders/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Better Folders

Better Folders offers a variety of options to improve your folder experience

Always show the folder icon, regardless of if the folder is open or not

Only have one folder open at a time

Open folders in a sidebar:

![A folder open in a separate sidebar](https://github.com/user-attachments/assets/432d3146-8091-4bae-9c1e-c19046c72947)
27 changes: 20 additions & 7 deletions src/plugins/betterFolders/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ enum FolderIconDisplay {
MoreThanOneFolderExpanded
}

const GuildsTree = findLazy(m => m.prototype?.moveNextTo);
const SortedGuildStore = findStoreLazy("SortedGuildStore");
export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore");
const SortedGuildStore = findStoreLazy("SortedGuildStore");
const GuildsTree = findLazy(m => m.prototype?.moveNextTo);
const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand");

let lastGuildId = null as string | null;
Expand Down Expand Up @@ -173,13 +173,13 @@ export default definePlugin({
{
predicate: () => !settings.store.keepIcons,
match: /(?<=\.Messages\.SERVER_FOLDER_PLACEHOLDER.+?useTransition\)\()/,
replace: "!!arguments[0].isBetterFolders&&"
replace: "$self.shouldShowTransition(arguments[0])&&"
},
// If we are rendering the normal GuildsBar sidebar, we avoid rendering guilds from folders that are expanded
{
predicate: () => !settings.store.keepIcons,
match: /expandedFolderBackground,.+?,(?=\i\(\(\i,\i,\i\)=>{let{key.{0,45}ul)(?<=selected:\i,expanded:(\i),.+?)/,
replace: (m, isExpanded) => `${m}!arguments[0].isBetterFolders&&${isExpanded}?null:`
replace: (m, isExpanded) => `${m}$self.shouldRenderContents(arguments[0],${isExpanded})?null:`
},
{
// Decide if we should render the expanded folder background if we are rendering the Better Folders sidebar
Expand All @@ -201,7 +201,7 @@ export default definePlugin({
replacement: {
// Render the Better Folders sidebar
match: /(?<=({className:\i\.guilds,themeOverride:\i})\))/,
replace: ",$self.FolderSideBar($1)"
replace: ",$self.FolderSideBar({...$1})"
}
},
{
Expand Down Expand Up @@ -306,7 +306,20 @@ export default definePlugin({
}
},

FolderSideBar: guildsBarProps => <FolderSideBar {...guildsBarProps} />,
shouldShowTransition(props: any) {
// Pending guilds
if (props.folderNode.id === 1) return true;

return !!props.isBetterFolders;
},

shouldRenderContents(props: any, isExpanded: boolean) {
// Pending guilds
if (props.folderNode.id === 1) return false;

return !props.isBetterFolders && isExpanded;
},

closeFolders
FolderSideBar,
closeFolders,
});

0 comments on commit 926ae50

Please sign in to comment.