-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivityAboveAccountPanel.tsx
104 lines (93 loc) · 2.92 KB
/
activityAboveAccountPanel.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { definePluginSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { findComponentByCodeLazy } from "@webpack";
import { PresenceStore, UserStore, useStateFromStores } from "@webpack/common";
interface Activity {
created_at: number;
id: string;
name: string;
type: number;
emoji?: {
animated: boolean;
id: string;
name: string;
};
state?: string;
flags?: number;
sync_id?: string;
details?: string;
application_id?: string;
assets?: {
large_text?: string;
large_image?: string;
small_text?: string;
small_image?: string;
};
timestamps?: Timestamp;
platform?: string;
}
interface Timestamp {
start?: number;
end?: number;
}
const ActivityView = findComponentByCodeLazy('location:"UserProfileActivityCard",');
const settings = definePluginSettings({
showButtons: {
type: OptionType.BOOLEAN,
description: "Show buttons",
default: false
}
});
export default definePlugin({
name: "ActivityAboveAccountPanel",
description: "Shows your activities above the account panel",
authors: [Devs.AutumnVN],
settings,
patches: [
{
find: "this.isCopiedStreakGodlike",
replacement: {
match: /(?<=\i\.jsxs?\)\()(\i),{(?=[^}]*?userTag:\i,hidePrivateData:)/,
replace: "$self.PanelWrapper,{VencordOriginal:$1,"
}
}
],
PanelWrapper({ VencordOriginal, ...props }) {
const currentUser = UserStore.getCurrentUser();
if (!currentUser) return null;
const activities = useStateFromStores<Activity[]>(
[PresenceStore], () => PresenceStore.getActivities(currentUser.id).filter((activity: Activity) => activity.type !== 4)
) ?? [];
return (
<>
<ErrorBoundary>
<div
style={{
display: "flex",
flexDirection: "column",
gap: "5px"
}}
>
{activities.map((activity, index) =>
(
<ActivityView
key={index}
activity={activity}
user={currentUser}
currentUser={settings.store.showButtons ? { id: "0" } : currentUser}
/>)
)}
</div>
</ErrorBoundary>
<VencordOriginal {...props} />
</>
);
}
});