From 6f3bba99b0f9963b08bca80cda2bf86c50783395 Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 26 Aug 2024 12:59:19 +0200 Subject: [PATCH] Fix Settings not returning as JSON --- Tranga/Server.cs | 2 +- Tranga/TrangaSettings.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Tranga/Server.cs b/Tranga/Server.cs index 935d466..8656758 100644 --- a/Tranga/Server.cs +++ b/Tranga/Server.cs @@ -198,7 +198,7 @@ public class Server : GlobalBase SendResponse(HttpStatusCode.OK, response, _parent.jobBoss.jobs.Where(jjob => jjob is DownloadNewChapters).OrderBy(jjob => ((DownloadNewChapters)jjob).manga.sortName)); break; case "Settings": - SendResponse(HttpStatusCode.OK, response, TrangaSettings.Serialize()); + SendResponse(HttpStatusCode.OK, response, TrangaSettings.AsJObject()); break; case "Settings/userAgent": SendResponse(HttpStatusCode.OK, response, TrangaSettings.userAgent); diff --git a/Tranga/TrangaSettings.cs b/Tranga/TrangaSettings.cs index e2b9390..ae5b91d 100644 --- a/Tranga/TrangaSettings.cs +++ b/Tranga/TrangaSettings.cs @@ -154,7 +154,7 @@ public static class TrangaSettings File.WriteAllText(settingsFilePath, Serialize()); } - public static string Serialize() + public static JObject AsJObject() { JObject jobj = new JObject(); jobj.Add("downloadLocation", JToken.FromObject(TrangaSettings.downloadLocation)); @@ -164,9 +164,11 @@ public static class TrangaSettings jobj.Add("aprilFoolsMode", JToken.FromObject(TrangaSettings.aprilFoolsMode)); jobj.Add("version", JToken.FromObject(TrangaSettings.version)); jobj.Add("requestLimits", JToken.FromObject(TrangaSettings.requestLimits)); - return jobj.ToString(); + return jobj; } + public static string Serialize() => AsJObject().ToString(); + public static void Deserialize(string serialized) { JObject jobj = JObject.Parse(serialized);