mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-22 08:09:12 -05:00
BetterActivities Remove Broken Section Temp
This commit is contained in:
parent
32b44e9822
commit
9e50746d02
1 changed files with 4 additions and 163 deletions
|
@ -12,11 +12,10 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
|||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
||||
import { PresenceStore, React, Tooltip, useEffect, useMemo, UserStore, useState, useStateFromStores } from "@webpack/common";
|
||||
import { React, Tooltip, UserStore } from "@webpack/common";
|
||||
import { User } from "discord-types/general";
|
||||
import { JSX } from "react";
|
||||
|
||||
import { Caret } from "./components/Caret";
|
||||
import { SpotifyIcon } from "./components/SpotifyIcon";
|
||||
import { TwitchIcon } from "./components/TwitchIcon";
|
||||
import { Activity, ActivityListIcon, Application, ApplicationIcon, IconCSSProperties } from "./types";
|
||||
|
@ -66,12 +65,6 @@ const settings = definePluginSettings({
|
|||
}} />
|
||||
),
|
||||
},
|
||||
userPopout: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show all activities in the profile popout/sidebar",
|
||||
default: true,
|
||||
restartNeeded: true,
|
||||
},
|
||||
allActivitiesStyle: {
|
||||
type: OptionType.SELECT,
|
||||
description: "Style for showing all activities",
|
||||
|
@ -314,167 +307,15 @@ export default definePlugin({
|
|||
return null;
|
||||
},
|
||||
|
||||
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>(
|
||||
activity?.type !== 4 ? activity! : null
|
||||
);
|
||||
|
||||
const activities = useStateFromStores<Activity[]>(
|
||||
[PresenceStore], () => PresenceStore.getActivities(user.id).filter((activity: Activity) => activity.type !== 4)
|
||||
) ?? [];
|
||||
|
||||
useEffect(() => {
|
||||
if (!activities.length) {
|
||||
setCurrentActivity(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!currentActivity || !activities.includes(currentActivity))
|
||||
setCurrentActivity(activities[0]);
|
||||
}, [activities]);
|
||||
|
||||
// we use these for other activities, it would be better to somehow get the corresponding activity props
|
||||
const generalProps = useMemo(() => Object.keys(props).reduce((acc, key) => {
|
||||
// exclude activity specific props to prevent copying them to all activities (e.g. buttons)
|
||||
if (key !== "renderActions" && key !== "application") acc[key] = props[key];
|
||||
return acc;
|
||||
}, {}), [props]);
|
||||
|
||||
if (!activities.length) return null;
|
||||
|
||||
if (settings.store.allActivitiesStyle === "carousel") {
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "column" }}>
|
||||
{activity && currentActivity?.id === activity?.id ? (
|
||||
<ActivityView
|
||||
activity={currentActivity}
|
||||
user={user}
|
||||
currentUser={currentUser}
|
||||
{...props}
|
||||
/>
|
||||
) : (
|
||||
<ActivityView
|
||||
activity={currentActivity}
|
||||
user={user}
|
||||
// fetch optional application
|
||||
application={getActivityApplication(currentActivity!)}
|
||||
currentUser={currentUser}
|
||||
{...generalProps}
|
||||
/>
|
||||
)}
|
||||
{activities.length > 1 &&
|
||||
<div
|
||||
className={cl("controls")}
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
}}
|
||||
>
|
||||
<Tooltip text="Left" tooltipClassName={cl("controls-tooltip")}>{({
|
||||
onMouseEnter,
|
||||
onMouseLeave
|
||||
}) => {
|
||||
return <span
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
onClick={() => {
|
||||
const index = activities.indexOf(currentActivity!);
|
||||
if (index - 1 >= 0)
|
||||
setCurrentActivity(activities[index - 1]);
|
||||
}}
|
||||
>
|
||||
<Caret
|
||||
disabled={activities.indexOf(currentActivity!) < 1}
|
||||
direction="left" />
|
||||
</span>;
|
||||
}}</Tooltip>
|
||||
|
||||
<div className="carousel">
|
||||
{activities.map((activity, index) => (
|
||||
<div
|
||||
key={"dot--" + index}
|
||||
onClick={() => setCurrentActivity(activity)}
|
||||
className={`dot ${currentActivity === activity ? "selected" : ""}`} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
<Tooltip text="Right" tooltipClassName={cl("controls-tooltip")}>{({
|
||||
onMouseEnter,
|
||||
onMouseLeave
|
||||
}) => {
|
||||
return <span
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
onClick={() => {
|
||||
const index = activities.indexOf(currentActivity!);
|
||||
if (index + 1 < activities.length)
|
||||
setCurrentActivity(activities[index + 1]);
|
||||
}}
|
||||
>
|
||||
<Caret
|
||||
disabled={activities.indexOf(currentActivity!) >= activities.length - 1}
|
||||
direction="right" />
|
||||
</span>;
|
||||
}}</Tooltip>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "5px",
|
||||
}}
|
||||
>
|
||||
{activities.map((activity, index) =>
|
||||
index === 0 ? (
|
||||
<ActivityView
|
||||
key={index}
|
||||
activity={activity}
|
||||
user={user}
|
||||
currentUser={currentUser}
|
||||
{...props}
|
||||
/>) : (
|
||||
<ActivityView
|
||||
key={index}
|
||||
activity={activity}
|
||||
user={user}
|
||||
application={getActivityApplication(activity)}
|
||||
currentUser={currentUser}
|
||||
{...generalProps}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
patches: [
|
||||
{
|
||||
// Patch activity icons
|
||||
find: '"activity-status-web"',
|
||||
replacement: {
|
||||
match: /\(null==\i?\?void 0:\i.some\(\i\.\i\)\)/,
|
||||
replace: "$self.patchActivityList(e),false"
|
||||
match: /(?<=hasQuest:\i\}=(\i).*?)\(null==\i?\?void 0:\i.some\(\i\.\i\)\)/,
|
||||
replace: "$self.patchActivityList($1),false"
|
||||
},
|
||||
predicate: () => settings.store.memberList,
|
||||
},
|
||||
{
|
||||
// Show all activities in the user popout/sidebar
|
||||
// still broken btw
|
||||
find: "#{intl::ACTIVITY_REACTION_REPLY_TITLE}",
|
||||
replacement: {
|
||||
match: /(?<=void 0:(\i\.type)\).{0,50}\(0,\i\.jsx\)\()(\i\.\i)(?=.{0,10},{activity:\i,user:\i,application:\i)/,
|
||||
replace: "$1==='BiteSizePopout'?$self.showAllActivitiesComponent:$2"
|
||||
},
|
||||
predicate: () => settings.store.userPopout
|
||||
},
|
||||
}
|
||||
],
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue