From 17db301ad6d2b6d3f112b9b7e264d01c057f4cd5 Mon Sep 17 00:00:00 2001 From: Oksamies Date: Tue, 21 Oct 2025 12:49:26 +0300 Subject: [PATCH] Fix package like action usage in package page As the package like action uses a toast, it needs the provided to be present, when it's fired up. This means that it can't be a globally "in the file" defined function, but rather has to be defined within the route function, so that it has access to the provider when it's initializedFix package like action usage in package page As the package like action uses a toast, it needs the provided to be present, when it's fired up. This means that it can't be a globally "in the file" defined function, but rather has to be defined within the route function, so that it has access to the provider when it's initialized. --- .../cyberstorm-remix/app/p/packageListing.tsx | 43 +++++++------------ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/apps/cyberstorm-remix/app/p/packageListing.tsx b/apps/cyberstorm-remix/app/p/packageListing.tsx index 51d463b49..1be05f52c 100644 --- a/apps/cyberstorm-remix/app/p/packageListing.tsx +++ b/apps/cyberstorm-remix/app/p/packageListing.tsx @@ -270,6 +270,12 @@ export default function PackageListing() { const listingAndTeamPromise = useMemo(() => Promise.all([listing, team]), []); + const packageLikeAction = PackageLikeAction({ + isLoggedIn: Boolean(currentUser?.username), + dataUpdateTrigger: fetchAndSetRatedPackages, + config: config, + }); + return ( <> @@ -434,8 +440,7 @@ export default function PackageListing() { listing={resolvedValue[0]} isLiked={isLiked} currentUser={currentUser} - likeUpdateTrigger={fetchAndSetRatedPackages} - requestConfig={config} + packageLikeAction={packageLikeAction} /> )} @@ -598,8 +603,7 @@ export default function PackageListing() { listing={resolvedValue[0]} isLiked={isLiked} currentUser={currentUser} - likeUpdateTrigger={fetchAndSetRatedPackages} - requestConfig={config} + packageLikeAction={packageLikeAction} /> )} @@ -953,34 +957,19 @@ function managementTools( ); } -function likeAction( - currentUser: CurrentUser | undefined, - updateTrigger: () => Promise, - requestConfig: () => RequestConfig -) { - return PackageLikeAction({ - isLoggedIn: Boolean(currentUser?.username), - dataUpdateTrigger: updateTrigger, - config: requestConfig, - }); -} - const Actions = memo(function Actions(props: { team: Awaited>; listing: Awaited>; isLiked: boolean; currentUser: CurrentUser | undefined; - likeUpdateTrigger: () => Promise; - requestConfig: () => RequestConfig; + packageLikeAction: ( + isLiked: boolean, + namespace: string, + packageName: string, + isLoggedIn: boolean + ) => void; }) { - const { - team, - listing, - isLiked, - currentUser, - likeUpdateTrigger, - requestConfig, - } = props; + const { team, listing, isLiked, currentUser, packageLikeAction } = props; return ( <> - likeAction(currentUser, likeUpdateTrigger, requestConfig)( + packageLikeAction( isLiked, listing.namespace, listing.name,