Skip to content

Commit d1a13c2

Browse files
authored
MessageLogger - Fix setting not saving correctly (#61)
1 parent b4aaa78 commit d1a13c2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

MessageLogger/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
version = "1.1.3"
1+
version = "1.1.4"
22
description = "Saves deleted / edited messages to a SQLite database and restores them when the channel is opened."
33

44
aliucord.changelog.set("""
5+
1.1.4
6+
======================
7+
8+
* fix setting not saving correctly
9+
510
1.1.3
11+
======================
612
713
* fix spamming debug logs with NPE
814

MessageLogger/src/main/java/io/github/juby210/acplugins/messagelogger/SQLite.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,14 @@ public void clearChannels() {
111111
}
112112

113113
public void setBoolSetting(String key, Boolean value) {
114-
String query = "UPDATE " + TABLE_NAME_SETTINGS + " SET value = ? WHERE name = ?";
114+
String query = "SELECT * FROM " + TABLE_NAME_SETTINGS + " WHERE name = ?";
115115
try (Cursor cursor = db.rawQuery(query, new String[]{ key })) {
116116
if (cursor.getCount() == 0) {
117117
query = "INSERT INTO " + TABLE_NAME_SETTINGS + " (name, value) VALUES (?, ?)";
118118
db.execSQL(query, new Object[]{ key, String.valueOf(value) });
119+
} else {
120+
query = "UPDATE " + TABLE_NAME_SETTINGS + " SET value = ? WHERE name = ?";
121+
db.execSQL(query, new Object[]{ String.valueOf(value), key });
119122
}
120123
}
121124
}

0 commit comments

Comments
 (0)