BetterActivities

This commit is contained in:
thororen1234 2024-09-28 18:26:50 -04:00
parent 157a363235
commit 677055aff3
2 changed files with 19 additions and 11 deletions

View file

@ -12,7 +12,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
import { PresenceStore, React, Tooltip, useEffect, useMemo, useState, useStateFromStores } from "@webpack/common"; import { PresenceStore, React, Tooltip, useEffect, useMemo, UserStore, useState, useStateFromStores } from "@webpack/common";
import { User } from "discord-types/general"; import { User } from "discord-types/general";
import { Caret } from "./components/Caret"; import { Caret } from "./components/Caret";
@ -102,8 +102,8 @@ const ActivityView = findComponentByCodeLazy<{
activity: Activity | null; activity: Activity | null;
user: User; user: User;
application?: Application; application?: Application;
type?: string; currentUser: User;
}>(",onOpenGameProfileModal:"); }>('location:"UserProfileActivityCard",');
// if discord one day decides to change their icon this needs to be updated // if discord one day decides to change their icon this needs to be updated
const DefaultActivityIcon = findComponentByCodeLazy("M6,7 L2,7 L2,6 L6,6 L6,7 Z M8,5 L2,5 L2,4 L8,4 L8,5 Z M8,3 L2,3 L2,2 L8,2 L8,3 Z M8.88888889,0 L1.11111111,0 C0.494444444,0 0,0.494444444 0,1.11111111 L0,8.88888889 C0,9.50253861 0.497461389,10 1.11111111,10 L8.88888889,10 C9.50253861,10 10,9.50253861 10,8.88888889 L10,1.11111111 C10,0.494444444 9.5,0 8.88888889,0 Z"); const DefaultActivityIcon = findComponentByCodeLazy("M6,7 L2,7 L2,6 L6,6 L6,7 Z M8,5 L2,5 L2,4 L8,4 L8,5 Z M8,3 L2,3 L2,2 L8,2 L8,3 Z M8.88888889,0 L1.11111111,0 C0.494444444,0 0,0.494444444 0,1.11111111 L0,8.88888889 C0,9.50253861 0.497461389,10 1.11111111,10 L8.88888889,10 C9.50253861,10 10,9.50253861 10,8.88888889 L10,1.11111111 C10,0.494444444 9.5,0 8.88888889,0 Z");
@ -113,6 +113,8 @@ const fetchedApplications = new Map<string, Application | null>();
const xboxUrl = "https://discord.com/assets/9a15d086141be29d9fcd.png"; // TODO: replace with "renderXboxImage"? const xboxUrl = "https://discord.com/assets/9a15d086141be29d9fcd.png"; // TODO: replace with "renderXboxImage"?
const ActivityTooltip = ({ activity, application, user }: Readonly<{ activity: Activity, application?: Application, user: User; }>) => { const ActivityTooltip = ({ activity, application, user }: Readonly<{ activity: Activity, application?: Application, user: User; }>) => {
const currentUser = UserStore.getCurrentUser();
if (!currentUser) return null;
return ( return (
<ErrorBoundary> <ErrorBoundary>
<div className={cl("activity-tooltip")}> <div className={cl("activity-tooltip")}>
@ -120,7 +122,7 @@ const ActivityTooltip = ({ activity, application, user }: Readonly<{ activity: A
activity={activity} activity={activity}
user={user} user={user}
application={application} application={application}
type="BiteSizePopout" currentUser={currentUser}
/> />
</div> </div>
</ErrorBoundary> </ErrorBoundary>
@ -311,7 +313,10 @@ export default definePlugin({
return null; return null;
}, },
showAllActivitiesComponent({ activity, user, ...props }: Readonly<{ activity: Activity | null; user: User; application: Application; type: string; }>) { showAllActivitiesComponent({ activity, user, ...props }: Readonly<{ activity: Activity; user: User; application: Application; type: string; }>) {
const currentUser = UserStore.getCurrentUser();
if (!currentUser) return null;
const [currentActivity, setCurrentActivity] = useState<Activity | null>( const [currentActivity, setCurrentActivity] = useState<Activity | null>(
activity?.type !== 4 ? activity! : null activity?.type !== 4 ? activity! : null
); );
@ -346,6 +351,7 @@ export default definePlugin({
<ActivityView <ActivityView
activity={currentActivity} activity={currentActivity}
user={user} user={user}
currentUser={currentUser}
{...props} {...props}
/> />
) : ( ) : (
@ -354,6 +360,7 @@ export default definePlugin({
user={user} user={user}
// fetch optional application // fetch optional application
application={getActivityApplication(currentActivity!)} application={getActivityApplication(currentActivity!)}
currentUser={currentUser}
{...generalProps} {...generalProps}
/> />
)} )}
@ -431,6 +438,7 @@ export default definePlugin({
key={index} key={index}
activity={activity} activity={activity}
user={user} user={user}
currentUser={currentUser}
{...props} {...props}
/>) : ( />) : (
<ActivityView <ActivityView
@ -438,6 +446,7 @@ export default definePlugin({
activity={activity} activity={activity}
user={user} user={user}
application={getActivityApplication(activity)} application={getActivityApplication(activity)}
currentUser={currentUser}
{...generalProps} {...generalProps}
/> />
))} ))}
@ -458,6 +467,7 @@ export default definePlugin({
}, },
{ {
// Show all activities in the user popout/sidebar // Show all activities in the user popout/sidebar
// still broken btw
find: '"UserActivityContainer"', find: '"UserActivityContainer"',
replacement: { replacement: {
match: /(?<=\(0,\i\.jsx\)\()(\i\.\i)(?=,{...(\i),activity:\i,user:\i,application:\i)/, match: /(?<=\(0,\i\.jsx\)\()(\i\.\i)(?=,{...(\i),activity:\i,user:\i,application:\i)/,

View file

@ -19,14 +19,12 @@
border-radius: 50%; border-radius: 50%;
} }
.vc-bactivities-activity-tooltip { [class*="tooltip_"]:has(.vc-bactivities-activity-tooltip) {
padding: 1px; max-width: 280px;
} }
.vc-bactivities-activity-tooltip img { .vc-bactivities-activity-tooltip {
width: 50px; margin: -5px;
height: 50px;
margin-right: 5px;
} }
.vc-bactivities-caret-left, .vc-bactivities-caret-left,