From 40169dc9daf31820c3edea5a93601dabdc169de4 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Mon, 19 Jan 2026 21:09:43 -0700 Subject: [PATCH] Fix profile like/dislike --- Assets/Scripts/ProfileMenu.cs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/Assets/Scripts/ProfileMenu.cs b/Assets/Scripts/ProfileMenu.cs index 6642877..00737d8 100644 --- a/Assets/Scripts/ProfileMenu.cs +++ b/Assets/Scripts/ProfileMenu.cs @@ -308,9 +308,7 @@ public class ProfileMenu : MonoBehaviour async Task SendPostVote(BigInteger postId, bool liked, TMP_Text entryLikesCount, TMP_Text entryLikesTexture) { - WWWForm dataForm = new(); - dataForm.AddField("liked", liked ? "1" : "0"); - using UnityWebRequest request = UnityWebRequest.Put(Endpoints.PROFILE_POSTS_ENDPOINT + "?id=" + postId.ToString(), dataForm.data); + using UnityWebRequest request = UnityWebRequest.Put(Endpoints.PROFILE_POSTS_ENDPOINT + $"?id={postId}&liked={liked}", new WWWForm().data); request.SetRequestHeader("Authorization", BazookaManager.Instance.GetAccountSession()); request.SetRequestHeader("Requester", "BerryDashClient"); request.SetRequestHeader("ClientVersion", Application.version); @@ -326,7 +324,7 @@ public class ProfileMenu : MonoBehaviour var jsonResponse = JObject.Parse(response); if ((bool)jsonResponse["success"]) { - BigInteger likes = BigInteger.Parse((string)jsonResponse["likes"]); + BigInteger likes = BigInteger.Parse((string)jsonResponse["data"]["likes"]); entryLikesCount.text = Tools.FormatWithCommas(likes); entryLikesTexture.text = likes < 0 ? "\\uf165" : "\\uf164"; entryLikesTexture.color = likes < 0 ? new Color(1f, 0f, 0.5f) : new Color(1f, 1f, 0f); @@ -334,15 +332,6 @@ public class ProfileMenu : MonoBehaviour likedPosts.Add(postId.ToString()); BazookaManager.Instance.SetLikedPosts(likedPosts); } - else - { - if ((string)jsonResponse["message"] == "You have already voted") - { - var likedPosts = BazookaManager.Instance.GetLikedPosts(); - likedPosts.Add(postId.ToString()); - BazookaManager.Instance.SetLikedPosts(likedPosts); - } - } } catch {