From 95a85c5ea46bd70839a171219438099e1d52e65d Mon Sep 17 00:00:00 2001 From: Natsumi Date: Wed, 19 Nov 2025 23:53:25 +1100 Subject: [PATCH] Refactor SQLite to inform user of database errors --- Dotnet/SQLite.cs | 31 ++----- Dotnet/WebApi.cs | 2 +- .../dialogs/GroupDialog/GroupDialog.vue | 4 +- .../InviteDialog/EditAndSendInviteDialog.vue | 2 +- src/service/sqlite.js | 86 +++++++++++++------ src/types/globals.d.ts | 9 +- .../EditAndSendInviteResponseDialog.vue | 9 +- 7 files changed, 83 insertions(+), 60 deletions(-) diff --git a/Dotnet/SQLite.cs b/Dotnet/SQLite.cs index 32a69747..bccb9d38 100644 --- a/Dotnet/SQLite.cs +++ b/Dotnet/SQLite.cs @@ -44,26 +44,15 @@ namespace VRCX m_Connection.Close(); m_Connection.Dispose(); } - - public string ExecuteJson(string sql, IDictionary args = null) + + // for Electron + public string ExecuteJson(string sql, IDictionary? args = null) { var result = Execute(sql, args); - if (result.Item1 != null) - { - return JsonSerializer.Serialize(new - { - status = "error", - message = result.Item1 - }); - } - return JsonSerializer.Serialize(new - { - status = "success", - data = result.Item2 - }); + return JsonSerializer.Serialize(result); } - public Tuple Execute(string sql, IDictionary args = null) + public object[][] Execute(string sql, IDictionary? args = null) { m_ConnectionLock.EnterReadLock(); try @@ -88,11 +77,7 @@ namespace VRCX } result.Add(values); } - return new Tuple(null, result.ToArray()); - } - catch (Exception ex) - { - return new Tuple(ex.Message, null); + return result.ToArray(); } finally { @@ -100,9 +85,9 @@ namespace VRCX } } - public int ExecuteNonQuery(string sql, IDictionary args = null) + public int ExecuteNonQuery(string sql, IDictionary? args = null) { - int result = -1; + var result = -1; m_ConnectionLock.EnterWriteLock(); try { diff --git a/Dotnet/WebApi.cs b/Dotnet/WebApi.cs index d7fd457e..cc35fc7f 100644 --- a/Dotnet/WebApi.cs +++ b/Dotnet/WebApi.cs @@ -130,7 +130,7 @@ namespace VRCX ); try { - var item = (object[])values.Item2[0]; + var item = values[0]; using var stream = new MemoryStream(Convert.FromBase64String((string)item[0])); _cookieContainer = new CookieContainer(); _cookieContainer.Add(System.Text.Json.JsonSerializer.Deserialize(stream)); diff --git a/src/components/dialogs/GroupDialog/GroupDialog.vue b/src/components/dialogs/GroupDialog/GroupDialog.vue index db3bb0aa..130935ae 100644 --- a/src/components/dialogs/GroupDialog/GroupDialog.vue +++ b/src/components/dialogs/GroupDialog/GroupDialog.vue @@ -957,7 +957,7 @@