Improvements again

This commit is contained in:
2026-02-02 14:31:40 -07:00
parent 7d7228f49a
commit 1ba758f235
2 changed files with 60 additions and 82 deletions

View File

@@ -289,28 +289,17 @@ public class ProfileMenu : MonoBehaviour
request.SetRequestHeader("ClientVersion", Application.version);
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
await request.SendWebRequest();
if (request.downloadHandler.text == null)
if (request.downloadHandler.text == null) return;
var jsonResponse = JObject.Parse(request.downloadHandler.text);
if ((bool)jsonResponse["success"])
{
return;
}
string response = request.downloadHandler.text;
try
{
var jsonResponse = JObject.Parse(response);
if ((bool)jsonResponse["success"])
{
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);
var likedPosts = BazookaManager.Instance.GetLikedPosts();
likedPosts.Add(postId.ToString());
BazookaManager.Instance.SetLikedPosts(likedPosts);
}
}
catch
{
Debug.LogError("Failed to proccess vote");
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);
var likedPosts = BazookaManager.Instance.GetLikedPosts();
likedPosts.Add(postId.ToString());
BazookaManager.Instance.SetLikedPosts(likedPosts);
}
}