From d1a13c2ee01ebd7394fc28bf8ccb5651c503dd0d Mon Sep 17 00:00:00 2001 From: RazerTexz <66409416+RazerTexz@users.noreply.github.com> Date: Tue, 16 Jul 2024 17:17:52 +0700 Subject: [PATCH] MessageLogger - Fix setting not saving correctly (#61) --- MessageLogger/build.gradle.kts | 8 +++++++- .../io/github/juby210/acplugins/messagelogger/SQLite.java | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/MessageLogger/build.gradle.kts b/MessageLogger/build.gradle.kts index 6a5a72d..4d476cb 100644 --- a/MessageLogger/build.gradle.kts +++ b/MessageLogger/build.gradle.kts @@ -1,8 +1,14 @@ -version = "1.1.3" +version = "1.1.4" description = "Saves deleted / edited messages to a SQLite database and restores them when the channel is opened." aliucord.changelog.set(""" + 1.1.4 + ====================== + + * fix setting not saving correctly + 1.1.3 + ====================== * fix spamming debug logs with NPE diff --git a/MessageLogger/src/main/java/io/github/juby210/acplugins/messagelogger/SQLite.java b/MessageLogger/src/main/java/io/github/juby210/acplugins/messagelogger/SQLite.java index 8126c85..8388bfa 100644 --- a/MessageLogger/src/main/java/io/github/juby210/acplugins/messagelogger/SQLite.java +++ b/MessageLogger/src/main/java/io/github/juby210/acplugins/messagelogger/SQLite.java @@ -111,11 +111,14 @@ public void clearChannels() { } public void setBoolSetting(String key, Boolean value) { - String query = "UPDATE " + TABLE_NAME_SETTINGS + " SET value = ? WHERE name = ?"; + String query = "SELECT * FROM " + TABLE_NAME_SETTINGS + " WHERE name = ?"; try (Cursor cursor = db.rawQuery(query, new String[]{ key })) { if (cursor.getCount() == 0) { query = "INSERT INTO " + TABLE_NAME_SETTINGS + " (name, value) VALUES (?, ?)"; db.execSQL(query, new Object[]{ key, String.valueOf(value) }); + } else { + query = "UPDATE " + TABLE_NAME_SETTINGS + " SET value = ? WHERE name = ?"; + db.execSQL(query, new Object[]{ String.valueOf(value), key }); } } }