Fix profile like/dislike
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user