Fix Collections
This commit is contained in:
parent
f4ea6320e9
commit
0cb558f9aa
5 changed files with 18 additions and 11 deletions
|
|
@ -12,7 +12,7 @@ import type { ReactNode } from "react";
|
|||
|
||||
const logger = new Logger("ProfileCollectionAPI");
|
||||
|
||||
export type ProfileCollectionFactory = (props: { user: User; isSideBar: boolean; }) => ReactNode | Promise<ReactNode> | null;
|
||||
export type ProfileCollectionFactory = (props: { user: User; isSideBar: boolean; isRedesignEnabled?: boolean; }) => ReactNode | Promise<ReactNode> | null;
|
||||
|
||||
export interface ProfileCollectionData {
|
||||
render: ProfileCollectionFactory;
|
||||
|
|
|
|||
|
|
@ -31,10 +31,16 @@ export default definePlugin({
|
|||
// dm sidebar
|
||||
{
|
||||
find: ".SIDEBAR,disableToolbar:",
|
||||
replacement: {
|
||||
match: /user:\i,widgets:.{0,100}?\}\),(?=.{0,100}unownedWishlistItems:\i,wishlistId:\i)/,
|
||||
replace: "$&Vencord.Api.ProfileCollections.renderProfileCollections({...arguments[0],isSideBar:true}),"
|
||||
}
|
||||
replacement: [
|
||||
{
|
||||
match: /user:\i,widgets:.{0,100}?\}\),(?=.{0,100}user:\i,currentUser:\i)/,
|
||||
replace: "$&arguments[0]?.isRedesignEnabled&&Vencord.Api.ProfileCollections.renderProfileCollections({...arguments[0],isSideBar:true}),"
|
||||
},
|
||||
{
|
||||
match: /user:\i,widgets:.{0,100}?\}\),(?=.{0,100}unownedWishlistItems:\i,wishlistId:\i)/,
|
||||
replace: "$&!arguments[0]?.isRedesignEnabled&&Vencord.Api.ProfileCollections.renderProfileCollections({...arguments[0],isSideBar:true}),"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const ProfileCardClasses = findCssClassesLazy("cardsList", "firstCardContainer",
|
|||
const ProfileCardContainerClasses = findCssClassesLazy("innerContainer", "icons", "icon", "displayCount", "displayCountText", "displayCountTextColor", "breadcrumb");
|
||||
const ProfileCardOverlayClasses = findCssClassesLazy("overlay", "isPrivate", "outer");
|
||||
|
||||
export function ProfilePopoutComponent({ id, isSideBar = false }: { id: string, isSideBar?: boolean; }) {
|
||||
export function ProfilePopoutComponent({ id, isSideBar = false, isRedesignEnabled = false }: { id: string, isSideBar?: boolean; isRedesignEnabled?: boolean; }) {
|
||||
const [repos, setRepos] = useState<GitHubRepo[]>([]);
|
||||
const [groups, setGroups] = useState<RepoGroup[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
|
@ -122,7 +122,7 @@ export function ProfilePopoutComponent({ id, isSideBar = false }: { id: string,
|
|||
</section>
|
||||
);
|
||||
|
||||
return isSideBar
|
||||
return isSideBar && !isRedesignEnabled
|
||||
? <div className={DMSideBarClasses.widgetPreviews}>{reposSection}</div>
|
||||
: reposSection;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,10 @@ interface CollapsedProfileSongsProps {
|
|||
data?: UserData;
|
||||
user: User;
|
||||
isSideBar: boolean;
|
||||
isRedesignEnabled?: boolean;
|
||||
}
|
||||
|
||||
export default function CollapsedProfileSongs({ data, user, isSideBar }: CollapsedProfileSongsProps) {
|
||||
export default function CollapsedProfileSongs({ data, user, isSideBar, isRedesignEnabled = false }: CollapsedProfileSongsProps) {
|
||||
const [renders, setRenders] = useState(new Map<string, RenderSongInfo>());
|
||||
const previews = useMemo(() => data?.slice(0, shownSongs), [data]);
|
||||
const userId = user?.id;
|
||||
|
|
@ -115,7 +116,7 @@ export default function CollapsedProfileSongs({ data, user, isSideBar }: Collaps
|
|||
</section>
|
||||
);
|
||||
|
||||
return isSideBar
|
||||
return isSideBar && !isRedesignEnabled
|
||||
? <div className={DMSideBarClasses.widgetPreviews}>{songsSection}</div>
|
||||
: songsSection;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ export default definePlugin({
|
|||
|
||||
renderProfileCollection: {
|
||||
priority: 0,
|
||||
render: ({ user, isSideBar = false }: { user: User; isSideBar?: boolean; }) => {
|
||||
render: ({ user, isSideBar = false, isRedesignEnabled = false }: { user: User; isSideBar?: boolean; isRedesignEnabled?: boolean; }) => {
|
||||
const [reviewData] = useAwaiter(() => getReviews(user.id, { limit: 4 }), { deps: [user.id], fallbackValue: null });
|
||||
|
||||
// Discord are masters at using a crap ton of html elements and css classes to create a simple ui that could have
|
||||
|
|
@ -202,7 +202,7 @@ export default definePlugin({
|
|||
</section>
|
||||
);
|
||||
|
||||
return isSideBar
|
||||
return isSideBar && !isRedesignEnabled
|
||||
? <div className={DMSideBarClasses.widgetPreviews}>{reviewsSection}</div>
|
||||
: reviewsSection;
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue