diff --git a/src/equicordplugins/themeLibrary/components/LikesComponent.tsx b/src/equicordplugins/themeLibrary/components/LikesComponent.tsx
index 14e3de26..c4a03029 100644
--- a/src/equicordplugins/themeLibrary/components/LikesComponent.tsx
+++ b/src/equicordplugins/themeLibrary/components/LikesComponent.tsx
@@ -5,8 +5,7 @@
*/
import * as DataStore from "@api/DataStore";
-import { Button, useEffect, useRef, UserStore, useState } from "@webpack/common";
-import type { User } from "discord-types/general";
+import { Button, useEffect, useRef, useState } from "@webpack/common";
import type { Theme, ThemeLikeProps } from "../types";
import { isAuthorized } from "../utils/auth";
@@ -25,14 +24,13 @@ export const LikesComponent = ({ themeId, likedThemes: initialLikedThemes }: { t
function getThemeLikes(themeId: Theme["id"]): number {
const themeLike = likedThemes?.likes.find(like => like.themeId === themeId as unknown as Number);
- return themeLike ? themeLike.userIds.length : 0;
+ return themeLike ? themeLike.likes : 0;
}
const handleLikeClick = async (themeId: Theme["id"]) => {
if (!isAuthorized()) return;
const theme = likedThemes?.likes.find(like => like.themeId === themeId as unknown as Number);
- const currentUser: User = UserStore.getCurrentUser();
- const hasLiked: boolean = (theme?.userIds.includes(currentUser.id) || themeId === "preview") ?? false;
+ const hasLiked: boolean = theme?.hasLiked ?? false;
const endpoint = hasLiked ? "/likes/remove" : "/likes/add";
const token = await DataStore.get("ThemeLibrary_uniqueToken");
@@ -46,9 +44,9 @@ export const LikesComponent = ({ themeId, likedThemes: initialLikedThemes }: { t
method: "POST",
headers: {
"Content-Type": "application/json",
+ "Authorization": `Bearer ${token}`,
},
body: JSON.stringify({
- token,
themeId: themeId,
}),
});
@@ -57,7 +55,12 @@ export const LikesComponent = ({ themeId, likedThemes: initialLikedThemes }: { t
const fetchLikes = async () => {
try {
- const response = await themeRequest("/likes/get");
+ const token = await DataStore.get("ThemeLibrary_uniqueToken");
+ const response = await themeRequest("/likes/get", {
+ headers: {
+ "Authorization": `Bearer ${token}`,
+ },
+ });
const data = await response.json();
setLikedThemes(data);
} catch (err) {
@@ -72,7 +75,7 @@ export const LikesComponent = ({ themeId, likedThemes: initialLikedThemes }: { t
debounce.current = false;
};
- const hasLiked = likedThemes?.likes.some(like => like.themeId === themeId as unknown as Number && like.userIds.includes(UserStore.getCurrentUser().id)) ?? false;
+ const hasLiked = likedThemes?.likes.some(like => like.themeId === themeId as unknown as Number && like?.hasLiked === true) ?? false;
return (
diff --git a/src/equicordplugins/themeLibrary/components/ThemeCard.tsx b/src/equicordplugins/themeLibrary/components/ThemeCard.tsx
index e2f85424..28da1769 100644
--- a/src/equicordplugins/themeLibrary/components/ThemeCard.tsx
+++ b/src/equicordplugins/themeLibrary/components/ThemeCard.tsx
@@ -49,9 +49,9 @@ export const ThemeCard: React.FC
= ({ theme, themeLinks, likedTh
const getUser = (id: string, username: string) => UserUtils.getUser(id) ?? makeDummyUser({ username, id });
const handleAddRemoveTheme = () => {
- const onlineThemeLinks = themeLinks.includes(`${apiUrl}/${theme.name}`)
- ? themeLinks.filter(link => link !== `${apiUrl}/${theme.name}`)
- : [...themeLinks, `${apiUrl}/${theme.name}`];
+ const onlineThemeLinks = themeLinks.includes(`${apiUrl}/${theme.id}`)
+ ? themeLinks.filter(link => link !== `${apiUrl}/${theme.id}`)
+ : [...themeLinks, `${apiUrl}/${theme.id}`];
setThemeLinks(onlineThemeLinks);
Vencord.Settings.themeLinks = onlineThemeLinks;
@@ -108,7 +108,7 @@ export const ThemeCard: React.FC = ({ theme, themeLinks, likedTh
if (source) {
VencordNative.native.openExternal(source);
} else {
- VencordNative.native.openExternal(`${apiUrl}/${theme.name}`);
+ VencordNative.native.openExternal(`${apiUrl}/${theme.id}`);
}
};
@@ -135,16 +135,16 @@ export const ThemeCard: React.FC = ({ theme, themeLinks, likedTh
)}
{!removeButtons && (
- < div style={{ marginTop: "8px", display: "flex", flexDirection: "row" }}>
+