diff --git a/src/allActivities/index.ts b/src/allActivities/index.ts index a2744cf..c9535a6 100644 --- a/src/allActivities/index.ts +++ b/src/allActivities/index.ts @@ -3,7 +3,7 @@ import { ExtensionWebpackModule, Patch } from "@moonlight-mod/types"; export const patches: Patch[] = [ // Replace the existing activity/stream wrapper component with one we can add to easier { - find: /user:.,currentUser:.,stream:.,className:.+?user:.,currentUser:.,activity:.,className:/, + find: '"UserProfileFeaturedActivity"', replace: { match: /:function\(\){return (.)}/, replacement: ':function(){return require("allActivities_activities").default}' diff --git a/src/allActivities/webpackModules/activities.tsx b/src/allActivities/webpackModules/activities.tsx index 436c93a..7b94e1b 100644 --- a/src/allActivities/webpackModules/activities.tsx +++ b/src/allActivities/webpackModules/activities.tsx @@ -6,43 +6,85 @@ const UserProfileActivityCardWrapper = spacepack.findByCode('location:"' + 'User const UserProfileStreamActivityCard = spacepack.findByCode('surface:"' + 'user-profile-stream-activity-card",')[0] .exports.Z; const useUserProfileActivity = spacepack.findByCode('("use-user-' + 'profile-activity")')[0].exports.Z; +const useUserActivityFeedRecent = spacepack.findByCode( + '"application_id"in', + ".extra.application_id", + ".GAME_PROFILE_FEED" +)[0].exports.Z; +const ActivityFeedTimeUtils = spacepack.findByCode(".TRENDING_CONTENT))||void 0===")[0].exports; +const ActivityFeed48h = spacepack.findFunctionByStrings(ActivityFeedTimeUtils, ".Millis.HOUR<48"); +const UserProfileRecentActivityCard = spacepack.findByCode("{recentActivityEnabled:", ".bot?(0,")[0].exports.Z; type UserPopoutActivitiesProps = { user: any; // no discord common types :( currentUser: any; + profileGuildId: string; className: string; onClose: () => void; }; -export default function UserPopoutActivities({ user, currentUser, className, onClose }: UserPopoutActivitiesProps) { - const { live, stream } = useUserProfileActivity(user.id); +const LOCATION = "UserProfileFeaturedActivity"; + +export default function UserPopoutActivities({ + user, + currentUser, + profileGuildId, + className, + onClose +}: UserPopoutActivitiesProps) { + const { live, recent, stream } = useUserProfileActivity(user.id); const [firstActivity] = live; + + const isCurrentUser = user.id === currentUser.id; + + const recentFeedEntry = useUserActivityFeedRecent(user.id, LOCATION); + const feedEntry = React.useMemo( + () => (isCurrentUser ? recent.find(ActivityFeed48h) : recentFeedEntry), + [isCurrentUser, recent, recentFeedEntry] + ); + const activities = [...live]; activities.shift(); return [ null != stream ? ( ) : null != firstActivity ? ( + ) : feedEntry != null ? ( + ) : null, ...activities.map((activity: any) => ( diff --git a/src/mediaTweaks/index.ts b/src/mediaTweaks/index.ts index 64ee21c..8809fea 100644 --- a/src/mediaTweaks/index.ts +++ b/src/mediaTweaks/index.ts @@ -14,7 +14,7 @@ export const patches: Patch[] = [ { find: ".TOGGLE_GIF_PICKER,handler:", replace: { - match: /.{1,2}===.\..\.CREATE_FORUM_POST/, + match: /[A-Za-z_$][\w$]*===[A-Za-z_$][\w$]*\.[A-Za-z_$][\w$]*\.CREATE_FORUM_POST/, replacement: (orig: string) => `(moonlight.getConfigOption("mediaTweaks","noGifAutosend")??true?true:${orig})` } }, @@ -34,9 +34,9 @@ export const patches: Patch[] = [ { find: 'location:"MessageAccessories"', replace: { - match: /=.\.length>1\?(\(0,.\..{1,2}\))\((.),({shouldRedactExplicitContent:.,shouldHideMediaOptions:.}),(.)\):{}/, + match: /=(\(0,.\..{1,2}\))\((.),({shouldRedactExplicitContent:.,shouldHideMediaOptions:.}),(.)\),/, replacement: (_, createCarousel, attachments, props, analytics) => - `=${attachments}.length>1?${createCarousel}((moonlight.getConfigOption("mediaTweaks","inlineMosaicPlayback")??true)?${attachments}.filter(x=>x.type!="VIDEO"):${attachments},${props},${analytics}):{}` + `=${createCarousel}((moonlight.getConfigOption("mediaTweaks","inlineMosaicPlayback")??true)?${attachments}.filter(x=>x.type!="VIDEO"):${attachments},${props},${analytics}),` } },